refactor: move mergePaths() to utils.ts (#2905)

This commit is contained in:
Tim Reichen
2025-05-12 09:59:37 +02:00
committed by GitHub
parent c6d4c47e00
commit 9605cd81b5
5 changed files with 33 additions and 32 deletions
-11
View File
@@ -28,17 +28,6 @@ export interface Router<T> {
export const IS_PATTERN = /[*:{}+?()]/;
export function mergePaths(a: string, b: string) {
if (a === "" || a === "/" || a === "/*") return b;
if (b === "/") return a;
if (a.endsWith("/")) {
return a.slice(0, -1) + b;
} else if (!b.startsWith("/")) {
return a + "/" + b;
}
return a + b;
}
export class UrlPatternRouter<T> implements Router<T> {
readonly _routes: Route<T>[] = [];
readonly _middlewares: T[] = [];