Socket
Socket
Sign inDemoInstall

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 3.1.3 to 3.1.4

README.md

110

ignore.js

@@ -109,9 +109,8 @@ 'use strict';

value: function _createRule(pattern) {
var rule_object = {
origin: pattern
};
var origin = pattern;
var negative = false;
// > An optional prefix "!" which negates the pattern;
if (pattern.indexOf('!') === 0) {
rule_object.negative = true;
negative = true;
pattern = pattern.substr(1);

@@ -126,6 +125,10 @@ }

rule_object.pattern = pattern;
rule_object.regex = regex(pattern);
var regex = make_regex(pattern, negative);
return rule_object;
return {
origin: origin,
pattern: pattern,
negative: negative,
regex: regex
};
}

@@ -202,3 +205,3 @@ }, {

var REPLACERS = [
var DEFAULT_REPLACER_PREFIX = [

@@ -215,3 +218,3 @@ // > Trailing spaces are ignored unless they are quoted with backslash ("\")

// replace (\ ) with ' '
[/\\\s/g, function (match) {
[/\\\s/g, function () {
return ' ';

@@ -266,27 +269,5 @@ }],

return '^(?:.*\\/)?';
}],
}]];
// 'f'
// matches
// - /f(end)
// - /f/
// - (start)f(end)
// - (start)f/
// doesn't match
// - oof
// - foo
// pseudo:
// -> (^|/)f(/|$)
// ending
[
// 'js' will not match 'js.'
// 'ab' will not match 'abc'
/(?:[^*\/])$/, function (match) {
// 'js*' will not match 'a.js'
// 'js/' will not match 'a.js'
// 'js' will match 'a.js' and 'a.js/'
return match + '(?=$|\\/)';
}],
var DEFAULT_REPLACER_SUFFIX = [
// starting

@@ -296,3 +277,3 @@ [

// If starts with '**', adding a '^' to the regular expression also works
/^(?=[^\^])/, function (match) {
/^(?=[^\^])/, function () {
return !/\/(?!$)/.test(this)

@@ -314,5 +295,5 @@ // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern

// should not use '*', or it will be replaced by the next replacer
function (m, index, str) {
// Check if it is not the last `'/**'`
// Check if it is not the last `'/**'`
function (match, index, str) {
return index + 6 < str.length

@@ -340,5 +321,7 @@

// 'abc.*' -> skip this rule
/(^|[^\\]+)\\\*(?=.+)/g, function (match, p1) {
// '*.js' matches '.js'
// '*.js' doesn't match 'abc'
/(^|[^\\]+)\\\*(?=.+)/g,
// '*.js' matches '.js'
// '*.js' doesn't match 'abc'
function (match, p1) {
return p1 + '[^\\/]*';

@@ -348,3 +331,3 @@ }],

// trailing wildcard
[/(\\\/)?\\\*$/, function (m, p1) {
[/(\\\/)?\\\*$/, function (match, p1) {
return p1 === '\\/'

@@ -364,2 +347,43 @@ // 'a/*' does not match 'a/'

var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [
// 'f'
// matches
// - /f(end)
// - /f/
// - (start)f(end)
// - (start)f/
// doesn't match
// - oof
// - foo
// pseudo:
// -> (^|/)f(/|$)
// ending
[
// 'js' will not match 'js.'
// 'ab' will not match 'abc'
/(?:[^*\/])$/,
// 'js*' will not match 'a.js'
// 'js/' will not match 'a.js'
// 'js' will match 'a.js' and 'a.js/'
function (match) {
return match + '(?=$|\\/)';
}]], DEFAULT_REPLACER_SUFFIX);
var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [
// #24
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
// A negative pattern without a trailing wildcard should not
// re-include the things inside that directory.
// eg:
// ['node_modules/*', '!node_modules']
// should ignore `node_modules/a.js`
[/(?:[^*\/])$/, function (match) {
return match + '(?=$|\\/$)';
}]], DEFAULT_REPLACER_SUFFIX);
// A simple cache, because an ignore rule only has only one certain meaning

@@ -369,3 +393,3 @@ var cache = {};

// @param {pattern}
function regex(pattern) {
function make_regex(pattern, negative) {
var r = cache[pattern];

@@ -376,3 +400,5 @@ if (r) {

var source = REPLACERS.reduce(function (prev, current) {
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
var source = replacers.reduce(function (prev, current) {
return prev.replace(current[0], current[1].bind(pattern));

@@ -379,0 +405,0 @@ }, pattern);

{
"name": "ignore",
"version": "3.1.3",
"version": "3.1.4",
"description": "Ignore is a manager and filter for .gitignore rules.",

@@ -5,0 +5,0 @@ "main": "./ignore.js",

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