Skip to content

Commit

Permalink
Chore: Remove overwrite from content-type rule
Browse files Browse the repository at this point in the history
`mime-db` now includes¹ the appropriate font media types, thus,
there is no longer a need to overwrite² the font media types.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ jshttp/mime-db#90
  jshttp/mime-db#77

² e35b778
  • Loading branch information
alrra authored and molant committed Oct 16, 2017
1 parent 3aea65c commit 5d23adb
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/lib/rules/content-type/content-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,6 @@ const rule: IRuleBuilder = {
return null;
};

const overwriteMediaType = (mediaType: string): string => {

/*
* TODO: The following is done because of a current limitation in `mime-db`.
* https://github.com/jshttp/mime-db/issues/20
*/

switch (mediaType) {
case 'application/x-font-otf':
return 'font/otf';
case 'application/font-sfnt':
return 'font/sfnt';
case 'application/x-font-ttf':
return 'font/ttf';
case 'application/font-woff':
return 'font/woff';
case 'application/font-woff2':
return 'font/woff2';
default:
return mediaType;
}
};

const validate = async (fetchEnd: IFetchEnd) => {
const { element, resource, response }: { element: IAsyncHTMLElement, resource: string, response: IResponse } = fetchEnd;

Expand Down Expand Up @@ -271,13 +248,11 @@ const rule: IRuleBuilder = {

// Try to determine the media type and charset of the resource.

let mediaType: string =
const mediaType: string =
determineMediaTypeBasedOnElement(element) ||
determineMediaTypeBasedOnFileType(response.body.rawContent) ||
determineMediaTypeBasedOnFileExtension(resource);

mediaType = overwriteMediaType(mediaType);

const charset: string = determineCharset(mediaType, originalMediaType);

/*
Expand Down

0 comments on commit 5d23adb

Please sign in to comment.