From db5c598a81a2da6d16d8e7b6ffacae180518a81f Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Wed, 1 Jan 2025 21:10:09 +0100 Subject: [PATCH] fix: fix the pass route not work with paths ending with "/" --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index bc8a71f..0339b1a 100644 --- a/src/index.js +++ b/src/index.js @@ -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