From 1251a8265c6c8fcff06f88cb0543e7ce0ddf7ad7 Mon Sep 17 00:00:00 2001 From: Lenny Date: Mon, 17 Nov 2025 10:40:16 -0500 Subject: [PATCH] fix: remove deuplicate slash in tus upload url generator --- src/http/routes/tus/lifecycle.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/http/routes/tus/lifecycle.ts b/src/http/routes/tus/lifecycle.ts index 536590b0d..0e7f911a0 100644 --- a/src/http/routes/tus/lifecycle.ts +++ b/src/http/routes/tus/lifecycle.ts @@ -126,7 +126,8 @@ export function generateUrl( const forwardedPath = req.headers['x-forwarded-prefix'] if (requestAllowXForwardedPrefix && typeof forwardedPath === 'string') { - basePath = forwardedPath + path + // Remove trailing slash from forwardedPath to avoid double slashes + basePath = forwardedPath.replace(/\/+$/, '') + path } const isSigned = req.url?.endsWith(SIGNED_URL_SUFFIX) @@ -264,7 +265,7 @@ export async function onUploadFinish(rawReq: Request, upload: Upload) { if (upload.metadata?.metadata) { try { customMd = JSON.parse(upload.metadata.metadata) - } catch (e) { + } catch { // no-op } }