Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Resolves null iteration bug in route lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesseanwright committed Nov 26, 2019
1 parent 8a33c0a commit d6b9c34
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Package.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion reno/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion reno/router_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d6b9c34

Please sign in to comment.