diff --git a/src/core/services/utils/mimetype.ts b/src/core/services/utils/mimetype.ts index 69d6496a9..dc537b7b5 100644 --- a/src/core/services/utils/mimetype.ts +++ b/src/core/services/utils/mimetype.ts @@ -312,17 +312,12 @@ export class CoreMimetypeUtilsProvider { * @returns The lowercased extension without the dot, or undefined. */ guessExtensionFromUrl(fileUrl: string): string | undefined { - const split = CoreUrl.removeUrlAnchor(fileUrl).split('.'); + const parsed = CoreUrl.parse(fileUrl); + const split = parsed?.path?.split('.'); let extension: string | undefined; - if (split.length > 1) { - let candidate = split[split.length - 1].toLowerCase(); - // Remove params if any. - const position = candidate.indexOf('?'); - if (position > -1) { - candidate = candidate.substring(0, position); - } - + if (split && split.length > 1) { + const candidate = split[split.length - 1].toLowerCase(); if (EXTENSION_REGEX.test(candidate)) { extension = candidate; }