Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ignore

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignore - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

51

index.js

@@ -357,8 +357,6 @@ // A simple implementation of make-array

const returnFalse = () => false
const checkPath = (path, doThrow) => {
const checkPath = (path, originalPath, doThrow) => {
if (!isString(path)) {
return doThrow(
`path must be a string, but got \`${path}\``,
`path must be a string, but got \`${originalPath}\``,
TypeError

@@ -373,7 +371,7 @@ )

//
if (REGEX_TEST_INVALID_PATH.test(path)) {
// Check if it is a relative path
if (checkPath.isNotRelative(path)) {
const r = '`path.relative()`d'
return doThrow(
`path should be a ${r} string, but got "${path}"`,
`path should be a ${r} string, but got "${originalPath}"`,
RangeError

@@ -386,2 +384,7 @@ )

const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)
checkPath.isNotRelative = isNotRelative
checkPath.convert = p => p
class Ignore {

@@ -485,5 +488,13 @@ constructor ({

// @returns {TestResult}
_test (path, cache, checkUnignored, slices) {
checkPath(path, throwError)
_test (originalPath, cache, checkUnignored, slices) {
const path = originalPath
// Supports nullable path
&& checkPath.convert(originalPath)
checkPath(path, originalPath, throwError)
return this._t(path, cache, checkUnignored, slices)
}
_t (path, cache, checkUnignored, slices) {
if (path in cache) {

@@ -506,3 +517,3 @@ return cache[path]

const parent = this._test(
const parent = this._t(
slices.join(SLASH) + SLASH,

@@ -542,4 +553,6 @@ cache,

const isPathValid = path => checkPath(path, returnFalse)
const returnFalse = () => false
const isPathValid = path =>
checkPath(path && checkPath.convert(path), path, returnFalse)

@@ -564,4 +577,2 @@ factory.isPathValid = isPathValid

) {
const test = Ignore.prototype._test
/* eslint no-control-regex: "off" */

@@ -573,10 +584,10 @@ const makePosix = str => /^\\\\\?\\/.test(str)

Ignore.prototype._test = function testWin32 (path, ...args) {
path = makePosix(path)
return test.call(this, path, ...args)
}
checkPath.convert = makePosix
factory.isPathValid = path => path
? isPathValid(makePosix(path))
: isPathValid(path)
// 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
// 'd:\\foo'
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i
checkPath.isNotRelative = path =>
REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
|| isNotRelative(path)
}

@@ -252,9 +252,5 @@ "use strict";

var returnFalse = function returnFalse() {
return false;
};
var checkPath = function checkPath(path, doThrow) {
var checkPath = function checkPath(path, originalPath, doThrow) {
if (!isString(path)) {
return doThrow("path must be a string, but got `".concat(path, "`"), TypeError);
return doThrow("path must be a string, but got `".concat(originalPath, "`"), TypeError);
} // We don't know if we should ignore '', so throw

@@ -265,8 +261,8 @@

return doThrow("path must not be empty", TypeError);
} //
} // Check if it is a relative path
if (REGEX_TEST_INVALID_PATH.test(path)) {
if (checkPath.isNotRelative(path)) {
var r = '`path.relative()`d';
return doThrow("path should be a ".concat(r, " string, but got \"").concat(path, "\""), RangeError);
return doThrow("path should be a ".concat(r, " string, but got \"").concat(originalPath, "\""), RangeError);
}

@@ -277,2 +273,12 @@

var isNotRelative = function isNotRelative(path) {
return REGEX_TEST_INVALID_PATH.test(path);
};
checkPath.isNotRelative = isNotRelative;
checkPath.convert = function (p) {
return p;
};
var Ignore =

@@ -380,5 +386,11 @@ /*#__PURE__*/

key: "_test",
value: function _test(path, cache, checkUnignored, slices) {
checkPath(path, throwError);
value: function _test(originalPath, cache, checkUnignored, slices) {
var path = originalPath // Supports nullable path
&& checkPath.convert(originalPath);
checkPath(path, originalPath, throwError);
return this._t(path, cache, checkUnignored, slices);
}
}, {
key: "_t",
value: function _t(path, cache, checkUnignored, slices) {
if (path in cache) {

@@ -400,3 +412,3 @@ return cache[path];

var parent = this._test(slices.join(SLASH) + SLASH, cache, checkUnignored, slices); // If the path contains a parent directory, check the parent first
var parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices); // If the path contains a parent directory, check the parent first

@@ -442,4 +454,8 @@

var returnFalse = function returnFalse() {
return false;
};
var isPathValid = function isPathValid(path) {
return checkPath(path, returnFalse);
return checkPath(path && checkPath.convert(path), path, returnFalse);
};

@@ -457,5 +473,3 @@

typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
var test = Ignore.prototype._test;
/* eslint no-control-regex: "off" */
var makePosix = function makePosix(str) {

@@ -465,15 +479,10 @@ return /^\\\\\?\\/.test(str) || /[\0-\x1F"<>\|]+/.test(str) ? str : str.replace(/\\/g, '/');

Ignore.prototype._test = function testWin32(path) {
path = makePosix(path);
checkPath.convert = makePosix; // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
// 'd:\\foo'
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
return test.call.apply(test, [this, path].concat(args));
checkPath.isNotRelative = function (path) {
return REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
};
factory.isPathValid = function (path) {
return path ? isPathValid(makePosix(path)) : isPathValid(path);
};
}
{
"name": "ignore",
"version": "5.1.0",
"version": "5.1.1",
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",

@@ -21,4 +21,5 @@ "files": [

"test:cases": "tap test/*.js --coverage",
"test-no-report": "npm run test:lint && npm run test:tsc && npm run test:ts && npm run test:cases",
"test": "npm run test-no-report",
"test:only": "npm run test:lint && npm run test:tsc && npm run test:ts && npm run test:cases",
"test": "npm run test:only",
"test:win32": "IGNORE_TEST_WIN32=1 npm run test",
"posttest": "tap --coverage-report=html && codecov"

@@ -25,0 +26,0 @@ },

@@ -182,2 +182,5 @@ <table><thead>

// WRONG, that it is an absolute path on Windows, an error will be thrown
ig.ignores('C:\\abc')
// Right

@@ -184,0 +187,0 @@ ig.ignores('abc')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc