diff --git a/Package.toml b/Package.toml index 50fad5e..8505571 100644 --- a/Package.toml +++ b/Package.toml @@ -1,3 +1,3 @@ name = "james@entropic.jamesswright.co.uk/reno" description = "A thin routing library designed to sit on top of Deno's standard HTTP module" -version = "0.6.3" +version = "0.6.4" diff --git a/reno/router.ts b/reno/router.ts index 76d6a1c..d9e8384 100644 --- a/reno/router.ts +++ b/reno/router.ts @@ -69,7 +69,7 @@ export const routerCreator = ( const queryParams = rootQueryParams || url.searchParams; for (let [path, handler] of routes) { - const [firstMatch, ...restMatches] = url.pathname.match(pathParser(path)); + const [firstMatch, ...restMatches] = url.pathname.match(pathParser(path)) || []; if (firstMatch) { const res = await handler( diff --git a/reno/router_test.ts b/reno/router_test.ts index 00c4551..a966fbd 100644 --- a/reno/router_test.ts +++ b/reno/router_test.ts @@ -90,7 +90,7 @@ test({ async fn() { const mismatchedRequest = await createServerRequest({ path: "/foo-bar" }); const routeStub = sinon.stub(); - const createRouter = routerCreator(sinon.stub(), sinon.stub()); + const createRouter = routerCreator(parsePath, sinon.stub()); const router = createRouter(createRouteMap([[/^\/foo$/, routeStub]])); await router(mismatchedRequest)