fix: fix the pass route not work with paths ending with "/"
This commit is contained in:
parent
f7a6bc4f6a
commit
db5c598a81
1 changed files with 3 additions and 2 deletions
|
@ -72,13 +72,14 @@ function svrouter() {
|
|||
} else if (callback && typeof path !== "string") {
|
||||
throw new Error("The path must be a function");
|
||||
}
|
||||
const realPath = callback ? path.replace(/\/+$/, "") : null;
|
||||
|
||||
routes.push({
|
||||
method: null,
|
||||
pathFunction: callback
|
||||
? (checkedPath) =>
|
||||
checkedPath == path ||
|
||||
checkedPath.substring(0, path.length + 1) == path + "/"
|
||||
checkedPath == realPath ||
|
||||
checkedPath.substring(0, realPath.length + 1) == realPath + "/"
|
||||
? {
|
||||
path: checkedPath,
|
||||
params: null
|
||||
|
|
Loading…
Reference in a new issue