Skip to content

Commit 54a5b93

Browse files
committed
update path-to-regexp
1 parent 3f97285 commit 54a5b93

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

package-lock.json

Lines changed: 8 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/inferno-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"dependencies": {
5151
"history": "^5.3.0",
5252
"inferno": "9.0.4",
53-
"path-to-regexp": "^1.9.0"
53+
"path-to-regexp": "^8.3.0"
5454
},
5555
"devDependencies": {
5656
"inferno-server": "9.0.4",

packages/inferno-router/src/matchPath.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pathToRegexp from 'path-to-regexp';
1+
import { pathToRegexp } from 'path-to-regexp';
22
import { type Match } from './Route';
33

44
const patternCache = {};
@@ -24,8 +24,13 @@ const compilePath = (pattern, options): { re: any; keys: pathToRegexKey[] } => {
2424
return cache[pattern];
2525
}
2626

27-
const keys = [];
28-
const re = pathToRegexp(pattern, keys, options);
27+
options.trailing = options.end && !options.strict;
28+
pattern = pattern.replace(/\?/, '{.:optqspunct}');
29+
if (!options.exact && !options.strict) {
30+
pattern = pattern.replace(/\/$/, '{.:optendslash}');
31+
}
32+
33+
const { regexp: re, keys } = pathToRegexp(pattern, options)
2934
const compiledPattern = { re, keys };
3035

3136
if (cacheCount < cacheLimit) {
@@ -79,4 +84,4 @@ export function matchPath(pathname, options: any): Match<any> | null {
7984
path, // the path pattern used to match
8085
url: path === '/' && url === '' ? '/' : url, // the matched portion of the URL
8186
};
82-
}
87+
}

0 commit comments

Comments
 (0)