Skip to content

Commit

Permalink
Fix exception on filepaths higher than ignore base
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 30, 2020
1 parent 876a9c2 commit 458be8e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = Ignore

Ignore.prototype.check = check

var sep = path.sep
var dirname = path.dirname
var relative = path.relative
var resolve = path.resolve
Expand Down Expand Up @@ -36,7 +37,17 @@ function check(filePath, callback) {
callback(error)
} else if (ignore) {
normal = relative(ignore.filePath, resolve(self.cwd, filePath))
callback(null, normal ? ignore.ignores(normal) : false)

if (
normal === '' ||
normal === '..' ||
normal.charAt(0) === sep ||
normal.slice(0, 3) === '..' + sep
) {
callback(null, false)
} else {
callback(null, ignore.ignores(normal))
}
} else {
callback(null, false)
}
Expand Down

0 comments on commit 458be8e

Please sign in to comment.