From 1446fe4694a6b4a6483bcc78b110c8da413a3c59 Mon Sep 17 00:00:00 2001 From: Patrik Date: Wed, 18 Dec 2024 14:37:29 -0500 Subject: [PATCH] fix: encodes upload filename urls (#10048) ### What? Previously, upload files urls were not being encoded. ### Why? As a result, this could lead to discrepancies where upload filenames with spaces - the spaces would not be encoded as %20 in the URL. ### How? To address this issue, we simply need to encode the filename of the upload media. Fixes #9698 --- packages/payload/src/uploads/getBaseFields.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/payload/src/uploads/getBaseFields.ts b/packages/payload/src/uploads/getBaseFields.ts index e035f2abdd..eee20baf6a 100644 --- a/packages/payload/src/uploads/getBaseFields.ts +++ b/packages/payload/src/uploads/getBaseFields.ts @@ -12,7 +12,7 @@ type GenerateURLArgs = { } const generateURL = ({ collectionSlug, config, filename }: GenerateURLArgs) => { if (filename) { - return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${filename}` + return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${encodeURIComponent(filename)}` } return undefined }