MOBILE-3947 core: Fix extension detection in guessExtensionFromUrl
parent
dfd7f89491
commit
03eb3e7dcb
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue