Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/Cache/AssetMemoryMap/
MimeFromExtension.rs

1//! Map a file extension to its IANA media type. Mirrors the inline helper in
2//! `Binary/Build/Scheme.rs` so the cache layer is self-contained.
3
4use std::path::Path;
5
6pub fn Fn(Path:&Path) -> &'static str {
7	match Path.extension().and_then(|S| S.to_str()).unwrap_or("") {
8		"js" | "mjs" | "cjs" => "application/javascript; charset=utf-8",
9
10		"css" => "text/css; charset=utf-8",
11
12		"html" | "htm" => "text/html; charset=utf-8",
13
14		"json" | "map" => "application/json; charset=utf-8",
15
16		"svg" => "image/svg+xml",
17
18		"png" => "image/png",
19
20		"jpg" | "jpeg" => "image/jpeg",
21
22		"gif" => "image/gif",
23
24		"webp" => "image/webp",
25
26		"woff" => "font/woff",
27
28		"woff2" => "font/woff2",
29
30		"ttf" => "font/ttf",
31
32		"otf" => "font/otf",
33
34		"wasm" => "application/wasm",
35
36		"ico" => "image/x-icon",
37
38		"txt" => "text/plain; charset=utf-8",
39
40		"md" => "text/markdown; charset=utf-8",
41
42		_ => "application/octet-stream",
43	}
44}