Skip to content

Commit

Permalink
add svg/woff mime types to mime.ts, #75061
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 13, 2019
1 parent a280393 commit ddd555c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
62 changes: 32 additions & 30 deletions src/vs/base/common/mime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,52 +274,54 @@ interface MapExtToMediaMimes {

// Known media mimes that we can handle
const mapExtToMediaMimes: MapExtToMediaMimes = {
'.aac': 'audio/x-aac',
'.avi': 'video/x-msvideo',
'.bmp': 'image/bmp',
'.flv': 'video/x-flv',
'.gif': 'image/gif',
'.jpg': 'image/jpg',
'.jpeg': 'image/jpg',
'.jpe': 'image/jpg',
'.png': 'image/png',
'.tiff': 'image/tiff',
'.tif': 'image/tiff',
'.ico': 'image/x-icon',
'.tga': 'image/x-tga',
'.psd': 'image/vnd.adobe.photoshop',
'.webp': 'image/webp',
'.jpe': 'image/jpg',
'.jpeg': 'image/jpg',
'.jpg': 'image/jpg',
'.m1v': 'video/mpeg',
'.m2a': 'audio/mpeg',
'.m2v': 'video/mpeg',
'.m3a': 'audio/mpeg',
'.mid': 'audio/midi',
'.midi': 'audio/midi',
'.mp4a': 'audio/mp4',
'.mpga': 'audio/mpeg',
'.mk3d': 'video/x-matroska',
'.mks': 'video/x-matroska',
'.mkv': 'video/x-matroska',
'.mov': 'video/quicktime',
'.movie': 'video/x-sgi-movie',
'.mp2': 'audio/mpeg',
'.mp2a': 'audio/mpeg',
'.mp3': 'audio/mpeg',
'.m2a': 'audio/mpeg',
'.m3a': 'audio/mpeg',
'.oga': 'audio/ogg',
'.ogg': 'audio/ogg',
'.spx': 'audio/ogg',
'.aac': 'audio/x-aac',
'.wav': 'audio/x-wav',
'.wma': 'audio/x-ms-wma',
'.mp4': 'video/mp4',
'.mp4a': 'audio/mp4',
'.mp4v': 'video/mp4',
'.mpg4': 'video/mp4',
'.mpe': 'video/mpeg',
'.mpeg': 'video/mpeg',
'.mpg': 'video/mpeg',
'.mpe': 'video/mpeg',
'.m1v': 'video/mpeg',
'.m2v': 'video/mpeg',
'.mpg4': 'video/mp4',
'.mpga': 'audio/mpeg',
'.oga': 'audio/ogg',
'.ogg': 'audio/ogg',
'.ogv': 'video/ogg',
'.png': 'image/png',
'.psd': 'image/vnd.adobe.photoshop',
'.qt': 'video/quicktime',
'.mov': 'video/quicktime',
'.spx': 'audio/ogg',
'.svg': 'image/svg+xml',
'.tga': 'image/x-tga',
'.tif': 'image/tiff',
'.tiff': 'image/tiff',
'.wav': 'audio/x-wav',
'.webm': 'video/webm',
'.mkv': 'video/x-matroska',
'.mk3d': 'video/x-matroska',
'.mks': 'video/x-matroska',
'.webp': 'image/webp',
'.wma': 'audio/x-ms-wma',
'.wmv': 'video/x-ms-wmv',
'.flv': 'video/x-flv',
'.avi': 'video/x-msvideo',
'.movie': 'video/x-sgi-movie'
'.woff': 'application/font-woff',
};

export function getMediaMime(path: string): string | undefined {
Expand Down
10 changes: 6 additions & 4 deletions src/vs/workbench/browser/web.resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { IFileService } from 'vs/platform/files/common/files';
import { URI } from 'vs/base/common/uri';
import { getMediaMime } from 'vs/base/common/mime';

export class WebResources {

Expand Down Expand Up @@ -62,10 +63,11 @@ export class WebResources {
promises.push(Promise.resolve());

} else {
promises.push(this._fileService.readFile(URI.parse(remoteUrl, true)).then(file => {
// todo@joh hack
const type = /\.woff$/.test(remoteUrl) ? 'application/font-woff' : 'image/svg+xml';
this._cache.set(remoteUrl, URL.createObjectURL(new Blob([file.value.buffer], { type })));
const uri = URI.parse(remoteUrl, true);
promises.push(this._fileService.readFile(uri).then(file => {
this._cache.set(remoteUrl, URL.createObjectURL(new Blob(
[file.value.buffer], { type: getMediaMime(uri.path) }
)));
}));
}
}
Expand Down

0 comments on commit ddd555c

Please sign in to comment.