tenebrous-dicebot/api/node_modules/rechoir/lib/extension.js

20 lines
464 B
JavaScript
Raw Normal View History

var path = require('path');
var EXTRE = /\.[^.]*/g;
var LONGEXTRE = /^[.]?[^.]+([.].+[^.])$/;
module.exports = function(input) {
var basename = path.basename(input);
var longExtension = LONGEXTRE.exec(basename);
if (!longExtension) {
return;
}
var possibleExtensions = longExtension[1].match(EXTRE);
if (!possibleExtensions) {
return;
}
return possibleExtensions.map(function(_, idx, exts) {
return exts.slice(idx).join('');
});
};