Skip to content

Commit

Permalink
Merge pull request #567 from BloomBooks/BL_13338DownloadedFilesWithSp…
Browse files Browse the repository at this point in the history
…aces

Fix BL-13338, make downloads not show spaces as "+" (#567)
  • Loading branch information
StephenMcConnel authored Aug 7, 2024
2 parents 45efa09 + 81804e5 commit 41cf493
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/BookDetail/ArtifactHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 41cf493

Please sign in to comment.