Skip to content

Commit 1a49166

Browse files
committed
Known media exts instead of known code text exts
Fixes #3446
1 parent 2cc9d6a commit 1a49166

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

src/common/uri.ts

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,58 @@ export interface GitUriOptions {
6060
}
6161

6262
const ImageMimetypes = ['image/png', 'image/gif', 'image/jpeg', 'image/webp', 'image/tiff', 'image/bmp'];
63-
// This list of extensions isn't exhaustive and is just intended to be a quick way to avoid checking the mime type of the file.
64-
const NonImageExtensions = ['.bat', '.c', '.csharp', '.cpp', '.css', '.go', '.html', '.java', '.js', '.md', '.php', '.ts'];
63+
// Known media types that VS Code can handle: https://github.com/microsoft/vscode/blob/a64e8e5673a44e5b9c2d493666bde684bd5a135c/src/vs/base/common/mime.ts#L33-L84
64+
const KnownMediaExtensions =[
65+
'.aac',
66+
'.avi',
67+
'.bmp',
68+
'.flv',
69+
'.gif',
70+
'.ico',
71+
'.jpe',
72+
'.jpeg',
73+
'.jpg',
74+
'.m1v',
75+
'.m2a',
76+
'.m2v',
77+
'.m3a',
78+
'.mid',
79+
'.midi',
80+
'.mk3d',
81+
'.mks',
82+
'.mkv',
83+
'.mov',
84+
'.movie',
85+
'.mp2',
86+
'.mp2a',
87+
'.mp3',
88+
'.mp4',
89+
'.mp4a',
90+
'.mp4v',
91+
'.mpe',
92+
'.mpeg',
93+
'.mpg',
94+
'.mpg4',
95+
'.mpga',
96+
'.oga',
97+
'.ogg',
98+
'.opus',
99+
'.ogv',
100+
'.png',
101+
'.psd',
102+
'.qt',
103+
'.spx',
104+
'.svg',
105+
'.tga',
106+
'.tif',
107+
'.tiff',
108+
'.wav',
109+
'.webm',
110+
'.webp',
111+
'.wma',
112+
'.wmv',
113+
'.woff'
114+
];
65115

66116
// a 1x1 pixel transparent gif, from http://png-pixel.com/
67117
export const EMPTY_IMAGE_URI = vscode.Uri.parse(
@@ -72,7 +122,7 @@ export async function asImageDataURI(uri: vscode.Uri, repository: Repository): P
72122
try {
73123
const { commit, baseCommit, headCommit, isBase, path } = JSON.parse(uri.query);
74124
const ext = pathUtils.extname(path);
75-
if (NonImageExtensions.includes(ext)) {
125+
if (!KnownMediaExtensions.includes(ext)) {
76126
return;
77127
}
78128
const ref = uri.scheme === 'review' ? commit : isBase ? baseCommit : headCommit;

0 commit comments

Comments
 (0)