diff --git a/app/lib/methods/handleMediaDownload.ts b/app/lib/methods/handleMediaDownload.ts index 3f899c741..28abab2d6 100644 --- a/app/lib/methods/handleMediaDownload.ts +++ b/app/lib/methods/handleMediaDownload.ts @@ -18,17 +18,12 @@ const defaultType = { export const LOCAL_DOCUMENT_DIRECTORY = FileSystem.documentDirectory; -const sanitizeString = (value: string) => { - const urlWithoutQueryString = value.split('?')[0]; - return sanitizeLikeString(urlWithoutQueryString.substring(urlWithoutQueryString.lastIndexOf('/') + 1)); -}; - -const serverUrlParsedAsPath = (serverURL: string) => `${sanitizeString(serverURL)}/`; +const serverUrlParsedAsPath = (serverURL: string) => `${sanitizeLikeString(serverURL)}/`; const sanitizeFileName = (value: string) => { const extension = value.substring(value.lastIndexOf('.') + 1); const toSanitize = value.substring(0, value.lastIndexOf('.')); - return `${sanitizeString(toSanitize)}.${extension}`; + return `${sanitizeLikeString(toSanitize)}.${extension}`; }; export const getFilename = ({ @@ -181,7 +176,7 @@ export const deleteMediaFiles = async (serverUrl: string): Promise => { const downloadQueue: { [index: string]: FileSystem.DownloadResumable } = {}; -export const mediaDownloadKey = (messageUrl: string) => `${sanitizeString(messageUrl)}`; +export const mediaDownloadKey = (messageUrl: string) => `${sanitizeLikeString(messageUrl)}`; export function isDownloadActive(messageUrl: string): boolean { return !!downloadQueue[mediaDownloadKey(messageUrl)];