Skip to content

Commit

Permalink
Bumps path-to-regexp and fixes breakage.
Browse files Browse the repository at this point in the history
  • Loading branch information
qubyte committed Sep 16, 2024
1 parent 8f3f6a9 commit 0c4311e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
44 changes: 26 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/router/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ function makeRoute(path, preNormalizedHandlers, options) {
const handlers = normalizeHandlers(preNormalizedHandlers);
const allowedMethods = Object.keys(handlers);
const allow = allowedMethods.sort().join(', ');
const regex = pathToRegexp(path, options);
const { keys, regexp } = pathToRegexp(path, options);

function notAllowed(_req, res) {
res.writeHead(405, { allow }).end();
}

return function match(req) {
const { pathname } = new URL(req.url, 'http://none');
const paramList = regex.exec(pathname);
const paramList = regexp.exec(pathname);

if (paramList) {
return {
params: makeParams(regex.keys, paramList),
params: makeParams(keys, paramList),
middlewares: handlers[req.method] || [notAllowed]
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@toisu/middleware-runner": "^4.0.0",
"path-to-regexp": "^7.0.0"
"path-to-regexp": "^8.1.0"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 0c4311e

Please sign in to comment.