refactor: move mergePaths() to utils.ts (#2905)
This commit is contained in:
@@ -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[] = [];
|
||||
|
||||
Reference in New Issue
Block a user