LibCore: Support audio file extensions when determining MIME type
Similar to commit bcfa4a3
, this enables navigating to a file:// URL in
Ladybird with audio file extensions.
The file extensions used here were taken from
https://docs.fileformat.com/audio/ (except QOA, which isn't listed).
This commit is contained in:
parent
f04ae5f542
commit
13e1f61a81
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/13e1f61a81 Pull-request: https://github.com/SerenityOS/serenity/pull/19479
1 changed files with 10 additions and 0 deletions
|
@ -102,6 +102,16 @@ StringView guess_mime_type_based_on_filename(StringView path)
|
|||
return "application/x-sheets+json"sv;
|
||||
if (path.ends_with(".webm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "video/webm"sv;
|
||||
if (path.ends_with(".flac"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "audio/flac"sv;
|
||||
if (path.ends_with(".mid"sv, CaseSensitivity::CaseInsensitive) || path.ends_with(".midi"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "audio/midi"sv;
|
||||
if (path.ends_with(".mp3"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "audio/mpeg"sv;
|
||||
if (path.ends_with(".qoa"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "audio/qoa"sv;
|
||||
if (path.ends_with(".wav"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "audio/wav"sv;
|
||||
// FIXME: Share this, TextEditor and HackStudio language detection somehow.
|
||||
auto basename = LexicalPath::basename(path);
|
||||
if (path.ends_with(".cpp"sv, CaseSensitivity::CaseInsensitive)
|
||||
|
|
Loading…
Add table
Reference in a new issue