Make router work with version 8 of path-to-regex
This commit is contained in:
parent
d2084d55f9
commit
35e323205f
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-router",
|
"name": "@tp/tp-router",
|
||||||
"version": "1.0.6",
|
"version": "1.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-router.js",
|
"main": "tp-router.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -164,7 +164,7 @@ export class TpRouter extends LitElement {
|
|||||||
if (path === '*') {
|
if (path === '*') {
|
||||||
this._catchAllRoute = {
|
this._catchAllRoute = {
|
||||||
path: path,
|
path: path,
|
||||||
regex: pathToRegexp('(.*)'),
|
regex: pathToRegexp('{/*path}'),
|
||||||
data: data,
|
data: data,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
@ -183,9 +183,7 @@ export class TpRouter extends LitElement {
|
|||||||
this.routes[namespace] = {};
|
this.routes[namespace] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = [];
|
const parsed = pathToRegexp(path);
|
||||||
const parsed = pathToRegexp(path, keys);
|
|
||||||
parsed.keys = keys;
|
|
||||||
|
|
||||||
this.routes[namespace][path] = {
|
this.routes[namespace][path] = {
|
||||||
path: path,
|
path: path,
|
||||||
@ -322,7 +320,7 @@ export class TpRouter extends LitElement {
|
|||||||
const params = route.params = {};
|
const params = route.params = {};
|
||||||
const qsIndex = path.indexOf('?');
|
const qsIndex = path.indexOf('?');
|
||||||
const pathname = qsIndex > -1 ? path.slice(0, qsIndex) : path;
|
const pathname = qsIndex > -1 ? path.slice(0, qsIndex) : path;
|
||||||
const m = route.regex.exec(decodeURIComponent(pathname));
|
const m = route.regex.regexp.exec(decodeURIComponent(pathname));
|
||||||
if (!m) return false;
|
if (!m) return false;
|
||||||
|
|
||||||
for (let i = 1, len = m.length; i < len; ++i) {
|
for (let i = 1, len = m.length; i < len; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user