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
This commit is contained in:
Patrik
2024-12-18 14:37:29 -05:00
committed by GitHub
parent f29e6335f6
commit 1446fe4694

View File

@@ -12,7 +12,7 @@ type GenerateURLArgs = {
} }
const generateURL = ({ collectionSlug, config, filename }: GenerateURLArgs) => { const generateURL = ({ collectionSlug, config, filename }: GenerateURLArgs) => {
if (filename) { if (filename) {
return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${filename}` return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${encodeURIComponent(filename)}`
} }
return undefined return undefined
} }