From 61e09642e53a4bdff1fdd6755379ff222e303a9e Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Wed, 1 Jan 2025 21:15:30 +0100 Subject: [PATCH] fix: change the condition for selecting the path function for pass-throughs --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 0339b1a..0859b41 100644 --- a/src/index.js +++ b/src/index.js @@ -72,11 +72,11 @@ function svrouter() { } else if (callback && typeof path !== "string") { throw new Error("The path must be a function"); } - const realPath = callback ? path.replace(/\/+$/, "") : null; + const realPath = callback ? path.replace(/\/+$/, "") : ""; routes.push({ 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 == realPath || checkedPath.substring(0, realPath.length + 1) == realPath + "/"