From 02eb8afd21a9a126ef891e029ab6a01aee00e655 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 29 Dec 2025 18:14:59 -0700 Subject: [PATCH] fix(forward slashes): Fixing express specific issue --- bin/server.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/server.js b/bin/server.js index 6a6d7a6..aad10ef 100644 --- a/bin/server.js +++ b/bin/server.js @@ -76,13 +76,13 @@ class Server { // URL normalization middleware - collapse multiple slashes app.use((req, res, next) => { - if (req.path && req.path.includes('//')) { + if (req.url && req.url.includes('//')) { + // Split URL into path and query string + const [path, queryString] = req.url.split('?') // Collapse multiple consecutive slashes into a single slash - const normalizedPath = req.path.replace(/\/+/g, '/') - // Reconstruct req.url with normalized path - const queryString = req.url.includes('?') ? req.url.substring(req.url.indexOf('?')) : '' - req.url = normalizedPath + queryString - req.path = normalizedPath + const normalizedPath = path.replace(/\/+/g, '/') + // Reconstruct req.url with normalized path (req.path is read-only and will auto-update) + req.url = queryString ? `${normalizedPath}?${queryString}` : normalizedPath } next() })