diff --git a/website/handlers/router.ts b/website/handlers/router.ts index 02746ec04..f1521bd82 100644 --- a/website/handlers/router.ts +++ b/website/handlers/router.ts @@ -99,9 +99,18 @@ export const router = ( } for (const { pathTemplate: routePath, handler } of routes) { - const pattern = urlPatternCache[routePath] ??= new URLPattern({ - pathname: routePath, - }); + const pattern = urlPatternCache[routePath] ??= (() => { + let url; + if (URL.canParse(routePath)) { + url = new URL(routePath); + } else { + url = new URL(routePath, "http://localhost:8000"); + } + return new URLPattern({ + pathname: url.pathname, + search: url.search, + }); + })(); const res = pattern.exec(req.url); const groups = res?.pathname.groups ?? {};