refactor(api): 🎨 Switch to base64url for proxy url encoding instead of plaintext

This commit is contained in:
Jesse Wierzbinski 2024-05-04 21:02:25 -10:00
parent 3be9d1d6ce
commit 5f785c391d
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -73,9 +73,10 @@ export const redirect = (url: string | URL, status = 302) => {
};
export const proxyUrl = (url: string | null) => {
const urlAsBase64Url = Buffer.from(url || "").toString("base64url");
return url
? new URL(
`/media/proxy?url=${encodeURIComponent(url)}`,
`/media/proxy?url=${urlAsBase64Url}`,
config.http.base_url,
).toString()
: url;