biofriction-wp-theme/node_modules/rev-path/index.js

19 lines
478 B
JavaScript
Raw Normal View History

2021-10-26 14:18:09 +02:00
'use strict';
const modifyFilename = require('modify-filename');
module.exports = (pth, hash) => {
if (!(pth && hash)) {
throw new Error('`path` and `hash` required');
}
return modifyFilename(pth, (filename, ext) => `${filename}-${hash}${ext}`);
};
module.exports.revert = (pth, hash) => {
if (!(pth && hash)) {
throw new Error('`path` and `hash` required');
}
return modifyFilename(pth, (filename, ext) => filename.replace(new RegExp(`-${hash}$`), '') + ext);
};