From 4f985692a675e3b8c6fd558463b88bb4173c1af4 Mon Sep 17 00:00:00 2001 From: James Harris Date: Sat, 13 May 2023 16:59:54 +0100 Subject: [PATCH] fix(formatThumbnailEmbed): escape characters in new URL path (#150) --- src/utils/formatThumbnailEmbed.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/formatThumbnailEmbed.ts b/src/utils/formatThumbnailEmbed.ts index b1eba9a0..5826ce01 100644 --- a/src/utils/formatThumbnailEmbed.ts +++ b/src/utils/formatThumbnailEmbed.ts @@ -1,3 +1,5 @@ +import { URL } from 'node:url' + /** * Converts the following URL: * @@ -11,7 +13,7 @@ export const formatThumbnailEmbed = (url: string): string => { if ( url.startsWith('https://storage.googleapis.com/zeepkist-gtr/thumbnails/') ) { - return url + return new URL(url).toString() } const baseUrlRegex = @@ -31,5 +33,5 @@ export const formatThumbnailEmbed = (url: string): string => { : part }) const newPath = newParts.join('/') - return baseUrl + newPath + return new URL(baseUrl + newPath).toString() }