Remove absolute paths

This commit is contained in:
CrazyMax
2020-04-08 00:33:20 +02:00
parent ff47e64685
commit fce5f2e313
342 changed files with 6646 additions and 7223 deletions
+6 -7
View File
@@ -10,13 +10,11 @@ const MAX_FILENAME_LENGTH = 100;
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g; // eslint-disable-line no-control-regex
const reRelativePath = /^\.+/;
const fn = (string, options) => {
const filenamify = (string, options = {}) => {
if (typeof string !== 'string') {
throw new TypeError('Expected a string');
}
options = options || {};
const replacement = options.replacement === undefined ? '!' : options.replacement;
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
@@ -38,9 +36,10 @@ const fn = (string, options) => {
return string;
};
fn.path = (pth, options) => {
pth = path.resolve(pth);
return path.join(path.dirname(pth), fn(path.basename(pth), options));
filenamify.path = (filePath, options) => {
filePath = path.resolve(filePath);
return path.join(path.dirname(filePath), filenamify(path.basename(filePath), options));
};
module.exports = fn;
module.exports = filenamify;
module.exports.default = filenamify;