MOBILE-2768 mimetype: Improve mimetype detection for PHP URLs

main
Dani Palou 2024-02-12 13:00:27 +01:00
parent 521dc9eb6d
commit 9b8414e8b4
1 changed files with 5 additions and 4 deletions

View File

@ -749,16 +749,17 @@ export class CoreUtilsProvider {
async getMimeTypeFromUrl(url: string): Promise<string> {
// First check if it can be guessed from the URL.
const extension = CoreMimetypeUtils.guessExtensionFromUrl(url);
let mimetype = extension && CoreMimetypeUtils.getMimeType(extension);
const mimetype = extension && CoreMimetypeUtils.getMimeType(extension);
if (mimetype) {
// Ignore PHP extension for now, it could be serving a file.
if (mimetype && extension !== 'php') {
return mimetype;
}
// Can't be guessed, get the remote mimetype.
mimetype = await CoreWS.getRemoteFileMimeType(url);
const remoteMimetype = await CoreWS.getRemoteFileMimeType(url);
return mimetype || '';
return remoteMimetype || mimetype || '';
}
/**