Datasets:
Download code/evaluation-code/ent400-a06a1576/apps/console/web/src/route.ts from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/apps/console/web/src/route.ts
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/ent400-a06a1576/apps/console/web/src/route.ts
-
curl -L -o route.ts https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/apps/console/web/src/route.ts
1.45 kB
| export type Route = {page: 'segments'} | {page: 'segment'; id: string; time: number; actors: string[] | null} | {page: 'config'} | {page: 'results'} | {page: 'verify'; run: string | null}; | |
| export function parseRoute(hash: string): Route { | |
| const [pathname, query = ''] = hash.replace(/^#/, '').split('?'); | |
| if (pathname === '/config') return {page: 'config'}; | |
| if (pathname === '/verify') return {page: 'verify', run: null}; | |
| if (pathname.startsWith('/verify/')) { | |
| try {return {page: 'verify', run: decodeURIComponent(pathname.slice('/verify/'.length)) || null};} | |
| catch {return {page: 'verify', run: null};} | |
| } | |
| if (pathname === '/results') return {page: 'results'}; | |
| const prefix = '/segments/'; | |
| if (!pathname.startsWith(prefix)) return {page: 'segments'}; | |
| try { | |
| const params = new URLSearchParams(query), rawTime = Number(params.get('t') ?? 0); | |
| return {page: 'segment', id: decodeURIComponent(pathname.slice(prefix.length)), | |
| time: Number.isFinite(rawTime) ? rawTime : 0, | |
| actors: params.has('actors') ? (params.get('actors') || '').split(',').filter(Boolean) : null}; | |
| } catch { return {page: 'segments'}; } | |
| } | |
| export function segmentHash(id: string, t = 0, actors: string[] | null = null): string { | |
| const params = new URLSearchParams({t: String(Math.round(t * 1000) / 1000)}); | |
| if (actors !== null) params.set('actors', actors.join(',')); | |
| return '#/segments/' + encodeURIComponent(id) + '?' + params; | |
| } | |