fix: change the condition for selecting the path function for pass-throughs

This commit is contained in:
Dorian Niemiec 2025-01-01 21:15:30 +01:00
parent 39a799ba08
commit 61e09642e5

View file

@ -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 + "/"