Skip to content

Commit

Permalink
use mime-score module for resolving extension contentions. Fixes #182
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Nov 25, 2017
1 parent 36de668 commit f548916
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -19,7 +19,9 @@
],
"description": "A comprehensive library for mime-type mapping",
"license": "MIT",
"dependencies": {},
"dependencies": {
"mime-score": "1.0.1"
},
"devDependencies": {
"chalk": "1.1.3",
"eslint": "4.6.1",
Expand Down
7 changes: 4 additions & 3 deletions src/build.js
Expand Up @@ -4,6 +4,7 @@

const fs = require('fs');
const path = require('path');
const mimeScore = require('mime-score');

let db = require('mime-db');
let chalk = require('chalk');
Expand Down Expand Up @@ -67,8 +68,8 @@ for (let type in db) {
if (ext in byExtension) {
const e0 = entry;
const e1 = byExtension[ext];
e0.pri = getScore(e0);
e1.pri = getScore(e1);
e0.pri = mimeScore(e0.type, e0.source);
e1.pri = mimeScore(e1.type, e1.source);

let drop = e0.pri < e1.pri ? e0 : e1;
let keep = e0.pri >= e1.pri ? e0 : e1;
Expand All @@ -95,7 +96,7 @@ Object.keys(db).sort().forEach(k => {
const entry = db[k];

if (entry.extensions) {
if (getScore(entry) >= STANDARD_FACET_SCORE) {
if (mimeScore(entry.type, entry.source) >= STANDARD_FACET_SCORE) {
standard[entry.type] = entry.extensions;
} else {
other[entry.type] = entry.extensions;
Expand Down

0 comments on commit f548916

Please sign in to comment.