fix: change the condition for selecting the path function for pass-throughs
This commit is contained in:
parent
39a799ba08
commit
61e09642e5
1 changed files with 2 additions and 2 deletions
|
@ -72,11 +72,11 @@ function svrouter() {
|
||||||
} else if (callback && typeof path !== "string") {
|
} else if (callback && typeof path !== "string") {
|
||||||
throw new Error("The path must be a function");
|
throw new Error("The path must be a function");
|
||||||
}
|
}
|
||||||
const realPath = callback ? path.replace(/\/+$/, "") : null;
|
const realPath = callback ? path.replace(/\/+$/, "") : "";
|
||||||
|
|
||||||
routes.push({
|
routes.push({
|
||||||
method: null,
|
method: null,
|
||||||
pathFunction: callback
|
pathFunction: realPath // If there is "/" path parameter, then the realPath variable will be "", which means that the pass-through will occur for all requests
|
||||||
? (checkedPath) =>
|
? (checkedPath) =>
|
||||||
checkedPath == realPath ||
|
checkedPath == realPath ||
|
||||||
checkedPath.substring(0, realPath.length + 1) == realPath + "/"
|
checkedPath.substring(0, realPath.length + 1) == realPath + "/"
|
||||||
|
|
Loading…
Reference in a new issue