提交 54fb49cd 编写于 作者: M Matt Bierner

Don't take user file associations into account for webview mime types

Fixes #62892
上级 8ec8c977
......@@ -106,7 +106,7 @@ export function clearTextMimes(onlyUserConfigured?: boolean): void {
/**
* Given a file, return the best matching mime type for it
*/
export function guessMimeTypes(path: string, firstLine?: string): string[] {
export function guessMimeTypes(path: string, firstLine?: string, skipUserAssociations: boolean = false): string[] {
if (!path) {
return [MIME_UNKNOWN];
}
......@@ -114,11 +114,13 @@ export function guessMimeTypes(path: string, firstLine?: string): string[] {
path = path.toLowerCase();
const filename = paths.basename(path);
if (!skipUserAssociations) {
// 1.) User configured mappings have highest priority
const configuredMime = guessMimeTypeByPath(path, filename, userRegisteredAssociations);
if (configuredMime) {
return [configuredMime, MIME_TEXT];
}
}
// 2.) Registered mappings have middle priority
const registeredMime = guessMimeTypeByPath(path, filename, nonUserRegisteredAssociations);
......
......@@ -52,5 +52,5 @@ const webviewMimeTypes = {
function getMimeType(normalizedPath: URI) {
const ext = extname(normalizedPath.fsPath).toLowerCase();
return webviewMimeTypes[ext] || getMediaMime(normalizedPath.fsPath) || guessMimeTypes(normalizedPath.fsPath)[0];
return webviewMimeTypes[ext] || getMediaMime(normalizedPath.fsPath) || guessMimeTypes(normalizedPath.fsPath, undefined, true)[0];
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册