import { Env } from "./types" ; export class Util { static contentPath ( id , env = Env . PROD ) { if ( env == Env . STAGING ) { return `/content-staging/${ Util . normalizeId ( id ) }` ; } else { return `/content/${ Util . normalizeId ( id ) }` ; } } static configPath ( id , env = Env . PROD ) { if ( env == Env . STAGING ) { return `/configs-staging/${ Util . normalizeId ( id ) }` ; } else { return `/configs/${ Util . normalizeId ( id ) }` ; } } /**
     * Make sure all IDs have the same casing, etc.f
     */ static normalizeId ( id ) { return id . toLowerCase ( ) ; } /**
     * Convert a path with slashes to a slug.
     */ static pathToSlug ( path ) { return this . normalizeId ( path . replace ( /\//g , "::" ) ) ; } /**
     * Parse a project ID slug into {owner,repo,path}.
     */ static parseProjectId ( id ) { const sections = id . split ( "::" ) ; if ( sections . length < 2 ) { throw `Invalid project id: ${ id }` ; } const owner = sections [ 0 ] ; const repo = sections [ 1 ] ; let path = undefined ; if ( sections . length > 2 ) { const pathSections = sections . slice ( 2 , sections . length ) ; path = pathSections . join ( "/" ) ; } return { owner , repo , path } ; } }