merge review/html-preview-mime: #972 serve preview assets with real MIME types
This commit is contained in:
commit
b1c33577be
4 files changed
+38
-4
No files matched your search
+11
-2
@@ -112,7 +112,7 @@ export interface SidebarFsLevel {
|
||||
/** Services required before mounting: routes, sessions, native request admission, and tools. */
|
||||
export const inject = ['webServer', 'sessions', 'connection', 'tools']
|
||||
|
||||
/** Content types for the media route, by extension. */
|
||||
/** Content types for media files and HTML preview resources, by extension. */
|
||||
const MEDIA_TYPES: Record<string, string> = {
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpeg',
|
||||
@@ -126,9 +126,18 @@ const MEDIA_TYPES: Record<string, string> = {
|
||||
'.pdf': 'application/pdf',
|
||||
'.html': 'text/html',
|
||||
'.htm': 'text/html',
|
||||
'.css': 'text/css',
|
||||
'.js': 'text/javascript',
|
||||
'.mjs': 'text/javascript',
|
||||
'.json': 'application/json',
|
||||
'.woff': 'font/woff',
|
||||
'.woff2': 'font/woff2',
|
||||
'.ttf': 'font/ttf',
|
||||
'.otf': 'font/otf',
|
||||
'.wasm': 'application/wasm',
|
||||
}
|
||||
|
||||
/** Content type served by /sidebar/file (binary-safe fallback for unknowns). */
|
||||
/** Content type served by /sidebar/file and /sidebar/html; unknowns use a binary-safe fallback. */
|
||||
export function mediaTypeForPath(path: string): string {
|
||||
return MEDIA_TYPES[extname(path).toLowerCase()] ?? 'application/octet-stream'
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user