Consolidate festival ID parsing functions

This commit is contained in:
Matt Isenhower 2023-02-11 14:25:52 -08:00
parent 3646814415
commit 9719317a53
3 changed files with 10 additions and 12 deletions

View File

@ -48,3 +48,11 @@ export function deriveId(node) {
...node,
};
}
export function getFestId(id) {
return Buffer.from(id, 'base64').toString().match(/^Fest-[A-Z]+:(.+)$/)?.[1] ?? id;
}
export function getFestTeamId(id) {
return Buffer.from(id, 'base64').toString().match(/^FestTeam-[A-Z]+:((.+):(.+))$/)?.[1] ?? id;
}

View File

@ -1,14 +1,7 @@
import fs from 'fs/promises';
import prefixedConsole from "../../common/prefixedConsole.mjs";
import DataUpdater from "./DataUpdater.mjs";
function getFestId(id) {
return Buffer.from(id, 'base64').toString().match(/^Fest-[A-Z]+:(.+)$/)?.[1] ?? id;
}
function getFestTeamId(id) {
return Buffer.from(id, 'base64').toString().match(/^FestTeam-[A-Z]+:((.+):(.+))$/)?.[1] ?? id;
}
import { getFestId, getFestTeamId } from '../../common/util.mjs';
export default class FestivalRankingUpdater extends DataUpdater
{

View File

@ -1,10 +1,7 @@
import fs from 'fs/promises';
import DataUpdater from "./DataUpdater.mjs";
import FestivalRankingUpdater from './FestivalRankingUpdater.mjs';
function getFestId(id) {
return Buffer.from(id, 'base64').toString().match(/^Fest-[A-Z]+:(.+)$/)?.[1] ?? id;
}
import { getFestId } from '../../common/util.mjs';
function generateFestUrl(id) {
return process.env.DEBUG ?