Sha256: facaa3974bfa27c832a629735077528b59cbc088fcfd2c22bbacba152c76ef2a

Contents?: true

Size: 1.32 KB

Versions: 36

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env node

'use strict';

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

let db = require('mime-db');
let chalk = require('chalk');

const STANDARD_FACET_SCORE = 900;

const byExtension = {};

// Clear out any conflict extensions in mime-db
for (let type in db) {
  let entry = db[type];
  entry.type = type;

  if (!entry.extensions) continue;

  entry.extensions.forEach(ext => {
    if (ext in byExtension) {
      const e0 = entry;
      const e1 = byExtension[ext];
      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;
      drop.extensions = drop.extensions.filter(e => e !== ext);

      console.log(`${ext}: Keeping ${chalk.green(keep.type)} (${keep.pri}), dropping ${chalk.red(drop.type)} (${drop.pri})`);
    }
    byExtension[ext] = entry;
  });
}

function writeTypesFile(types, path) {
  fs.writeFileSync(path, JSON.stringify(types));
}

// Segregate into standard and non-standard types based on facet per
// https://tools.ietf.org/html/rfc6838#section-3.1
const types = {};

Object.keys(db).sort().forEach(k => {
  const entry = db[k];
  types[entry.type] = entry.extensions;
});

writeTypesFile(types, path.join(__dirname, '..', 'types.json'));

Version data entries

36 entries across 32 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.18.0 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.18.2 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.16.1 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.15.2 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.18.4 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.18.1 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.14.0 test/dummy/node_modules/send/node_modules/mime/src/build.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/send/node_modules/mime/src/build.js
tang-0.2.1 spec/tang_app/node_modules/send/node_modules/mime/src/build.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/send/node_modules/mime/src/build.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/send/node_modules/mime/src/build.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/send/node_modules/mime/src/build.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/send/node_modules/mime/src/build.js
tang-0.2.0 spec/tang_app/node_modules/send/node_modules/mime/src/build.js
tang-0.1.0 spec/tang_app/node_modules/send/node_modules/mime/src/build.js
tang-0.0.9 spec/tang_app/node_modules/send/node_modules/mime/src/build.js
enju_library-0.3.8 spec/dummy/node_modules/send/node_modules/mime/src/build.js
ilog-0.4.1 node_modules/express/node_modules/mime/src/build.js