File size: 793 Bytes
2a93706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21ad36a
 
 
 
 
 
 
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
export interface BenchRouteLocation {
  pathname: string;
  search: string;
  hash: string;
}

export function isBenchRoute(location: BenchRouteLocation): boolean {
  const pathname = location.pathname.replace(/\/+$/, '');
  if (/(?:^|\/)bench(?:\/index\.html|\.html)?$/.test(pathname)) {
    return true;
  }

  if (new URLSearchParams(location.search).get('view') === 'bench') {
    return true;
  }

  return /^#\/?bench\/?$/.test(location.hash);
}

export function isPromptMatrixRoute(location: BenchRouteLocation): boolean {
  const pathname = location.pathname.replace(/\/+$/, '');
  return /(?:^|\/)prompt-matrix(?:\/index\.html|\.html)?$/.test(pathname)
    || new URLSearchParams(location.search).get('view') === 'prompt-matrix'
    || /^#\/?prompt-matrix\/?$/.test(location.hash);
}