master
 1export function joinUrl(...parts: string[]): string {
 2  const joined = parts.join('/');
 3  return joined.replace(/\/+/g, '/');
 4}
 5
 6export function pathsEqual(path1: string, path2: string) {
 7  const normalizedPath1 = path1.replace(/^\/|\/$/g, '').toLowerCase();
 8  const normalizedPath2 = path2.replace(/^\/|\/$/g, '').toLowerCase();
 9  return normalizedPath1 === normalizedPath2;
10}
11
12export function pathMatch(regex: RegExp, path: string) {
13  return regex.test(path) || regex.test(getRelativeUrl(path));
14}
15
16export function getRelativeUrl(path: string) {
17  return joinUrl('/', path.replace(import.meta.env.BASE_URL, ''));
18}
19
20export function url(path: string) {
21  return joinUrl('', import.meta.env.BASE_URL, path);
22}