mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibCore: Add some extensions that are text/plain
C++ source/header files, GML, IPC, CMake and various Serenity config files.
This commit is contained in:
parent
933a717f3b
commit
273b69f947
1 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
|
||||
|
@ -86,6 +87,20 @@ String guess_mime_type_based_on_filename(StringView path)
|
|||
return "text/html";
|
||||
if (path.ends_with(".csv", CaseSensitivity::CaseInsensitive))
|
||||
return "text/csv";
|
||||
// FIXME: Share this, TextEditor and HackStudio language detection somehow.
|
||||
auto basename = LexicalPath::basename(path);
|
||||
if (path.ends_with(".cpp", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".c", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".hpp", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".h", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".gml", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ini", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ipc", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".txt", CaseSensitivity::CaseInsensitive)
|
||||
|| basename == "CMakeLists.txt"
|
||||
|| basename == ".history"
|
||||
|| basename == ".shellrc")
|
||||
return "text/plain";
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue