From 81804e5b526acc59bb8c8471707cc9cd4118b24f Mon Sep 17 00:00:00 2001 From: Hatton Date: Wed, 7 Aug 2024 11:19:01 -0600 Subject: [PATCH] Fix BL-13338, make downloads not show spaces as "+" --- src/components/BookDetail/ArtifactHelper.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/BookDetail/ArtifactHelper.ts b/src/components/BookDetail/ArtifactHelper.ts index 40db1663..2b5422f1 100644 --- a/src/components/BookDetail/ArtifactHelper.ts +++ b/src/components/BookDetail/ArtifactHelper.ts @@ -46,6 +46,13 @@ export function getArtifactUrl( break; } if (!url) return ""; + + // Whatever writes the `baseUrl` to our books database encodes space as `+` (at least up through now, August 2024). + // This messes up the file name when you download, as you get "Hello+World.pdf". + // So here we just re-encode the `+` as `%20` and when downloaded the file is "Hello World.pdf". + // Since those URLs encode `+` as `%2b`, "one + one = two.pdf" will also to come out correctly. + url = url.replace(/\+/g, "%20"); + return url; }