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
+1 -15
View File
@@ -1,10 +1,5 @@
import { expect } from "@std/expect";
import {
IS_PATTERN,
mergePaths,
pathToPattern,
UrlPatternRouter,
} from "./router.ts";
import { IS_PATTERN, pathToPattern, UrlPatternRouter } from "./router.ts";
Deno.test("IS_PATTERN", () => {
expect(IS_PATTERN.test("/foo")).toEqual(false);
@@ -176,12 +171,3 @@ Deno.test("pathToPattern", async (t) => {
expect(() => pathToPattern("foo/[[name]]-bar")).toThrow();
});
});
Deno.test("mergePaths", () => {
expect(mergePaths("", "")).toEqual("");
expect(mergePaths("/", "/foo")).toEqual("/foo");
expect(mergePaths("/*", "/foo")).toEqual("/foo");
expect(mergePaths("/foo/bar", "/baz")).toEqual("/foo/bar/baz");
expect(mergePaths("/foo/bar/", "/baz")).toEqual("/foo/bar/baz");
expect(mergePaths("/foo/bar", "baz")).toEqual("/foo/bar/baz");
});