3 Commits
Author SHA1 Message Date
Chris Troutner b8f34fb40e Merge pull request #15 from Permissionless-Software-Foundation/ct-unstable
fix(forward slashes): Fixing express specific issue
2025-12-29 18:16:13 -07:00
Chris Troutner 3778894ce2 Merge branch 'master' into ct-unstable 2025-12-29 18:15:16 -07:00
Chris Troutner 02eb8afd21 fix(forward slashes): Fixing express specific issue 2025-12-29 18:14:59 -07:00
+6 -6
View File
@@ -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()
})