Skip to content

Commit

Permalink
5.1.6: better algo
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed May 22, 2020
1 parent 5753f0a commit 55ecc53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions index.js
Expand Up @@ -6,6 +6,7 @@ function makeArray (subject) {
}

const EMPTY = ''
const SPACE = ' '
const ESCAPE = '\\'
const REGEX_TEST_BLANK_LINE = /^\s+$/
const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/
Expand Down Expand Up @@ -41,10 +42,10 @@ const sanitizeRange = range => range.replace(
)

// See fixtures #59
const cleanRangeBackSlash = slashes => slashes.slice(
0,
parseInt(slashes.length / 2, 10) * 2
)
const cleanRangeBackSlash = slashes => {
const {length} = slashes
return slashes.slice(0, length - length % 2)
}

// > If the pattern ends with a slash,
// > it is removed for the purpose of the following description,
Expand All @@ -66,14 +67,14 @@ const REPLACERS = [
// (a \ ) -> (a )
/\\?\s+$/,
match => match.indexOf('\\') === 0
? ' '
? SPACE
: EMPTY
],

// replace (\ ) with ' '
[
/\\\s/g,
() => ' '
() => SPACE
],

// Escape metacharacters
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ignore",
"version": "5.1.5",
"version": "5.1.6",
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
"files": [
"legacy.js",
Expand Down

0 comments on commit 55ecc53

Please sign in to comment.