Skip to content

Commit

Permalink
Pass keys array to path-to-regexp (#160)
Browse files Browse the repository at this point in the history
Don't use deprecated `keys` and instead use the keys-array option.
  • Loading branch information
CarlRosell authored and taion committed Jan 8, 2018
1 parent f2c991a commit 3243cf4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ export default class Matcher {
}

const pattern = this.getCanonicalPattern(routePath);
const regexp = pathToRegexp(pattern, { end: false });
const keys = [];
const regexp = pathToRegexp(pattern, keys, { end: false });

const match = regexp.exec(pathname);
if (match === null) {
return null;
}

const params = Object.create(null);
regexp.keys.forEach(({ name }, index) => {
keys.forEach(({ name }, index) => {
const value = match[index + 1];
params[name] = value && decodeURIComponent(value);
});
Expand Down

0 comments on commit 3243cf4

Please sign in to comment.