mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-22 01:02:00 -07:00
fix(forward slashes): Adding middleware to detect multiple forward slashes in the URL
This commit is contained in:
@@ -74,6 +74,19 @@ class Server {
|
||||
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With']
|
||||
}))
|
||||
|
||||
// URL normalization middleware - collapse multiple slashes
|
||||
app.use((req, res, next) => {
|
||||
if (req.path && req.path.includes('//')) {
|
||||
// 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
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
// Apply basic auth middleware if enabled
|
||||
// This must run before x402 middleware to set req.locals.basicAuthValid
|
||||
if (basicAuthSettings.enabled) {
|
||||
|
||||
Reference in New Issue
Block a user