Skip to content

Commit 1251a82

Browse files
committed
fix: remove deuplicate slash in tus upload url generator
1 parent 4f66e94 commit 1251a82

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/http/routes/tus/lifecycle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export function generateUrl(
126126

127127
const forwardedPath = req.headers['x-forwarded-prefix']
128128
if (requestAllowXForwardedPrefix && typeof forwardedPath === 'string') {
129-
basePath = forwardedPath + path
129+
// Remove trailing slash from forwardedPath to avoid double slashes
130+
basePath = forwardedPath.replace(/\/+$/, '') + path
130131
}
131132

132133
const isSigned = req.url?.endsWith(SIGNED_URL_SUFFIX)
@@ -264,7 +265,7 @@ export async function onUploadFinish(rawReq: Request, upload: Upload) {
264265
if (upload.metadata?.metadata) {
265266
try {
266267
customMd = JSON.parse(upload.metadata.metadata)
267-
} catch (e) {
268+
} catch {
268269
// no-op
269270
}
270271
}

0 commit comments

Comments
 (0)