Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 9x 3x 15x 15x 9x 9x 5x | /**
* Turns a Leaderboard page path (`/players/...`) into a link to the Leaderboard of the environment the player runs in
* (docs/services.md section 1): `leaderboard.<site>` next to `play.<site>`, the preview Leaderboard from a branch Preview
* URL of the preview Player, and production anywhere else (a local dev server).
*/
export function leaderboardLink(path: string, hostname: string): string {
return `https://leaderboard.${leaderboardSite(hostname)}${path}`;
}
/** An avatar URL from the Leaderboard API, made absolute: a Leaderboard path resolves against {@link leaderboardLink}. */
export function leaderboardAvatarURL(url: string, hostname: string): string {
return url.startsWith('/') ? leaderboardLink(url, hostname) : url;
}
/** `be-music.app` for `play.be-music.app`, `preview.be-music.app` for `play.preview.be-music.app`, else undefined. */
export function siteOfPlayHost(hostname: string): string | undefined {
const match = /^play\.(.+)$/.exec(hostname.toLowerCase());
return match?.[1];
}
function leaderboardSite(hostname: string): string {
const site = siteOfPlayHost(hostname);
if (site !== undefined) return site;
return hostname.toLowerCase().endsWith('-play-preview.be-music.workers.dev')
? 'preview.be-music.app'
: 'be-music.app';
}
|