Comments (14)
Is it only when the path is absolute?
No, it's the same for relative paths as well. But it's only an issue when a dotfile is at the same level as **
- if it's inside a directory, it works correctly:
mm.isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**'); // => false; correct
from micromatch.
Actually, looking the tests.. they also looks wrong? not sure
mm.makeRe('.gitignore', {dot: true}).test('.gitignore').should.be.true;
mm.makeRe('.gitignore', {dot: false}).test('.gitignore').should.be.true;
mm.makeRe('.gitignore').test('.gitignore').should.be.true;
from micromatch.
Those tests are correct. It should match dotfiles even with dot: false
when dot is explicitly part of the pattern. dot: true/false
only affects wildcards.
from micromatch.
It should match dotfiles even
I don't think so. That's the idea of that option for me.
Nevermind, issue is for other bug.
from micromatch.
@jonschlinkert the whole point of this issue is because if we have directory with 1 file and 1 directory, and we want to pass foobar/**
pattern it will return only the 1 file and 1 directory without the foobar/
and this make sense because it comes as foobar
and pattern want at least foobar/
, so the trailing slash is problem. So i'm forced to add trailing slash before pass to micromatch.
Doesn't it make sense foobar/**
to match foobar
and foobar/
? Exactly because *
is zero or more?
from micromatch.
It should match dotfiles even with dot: false when dot is explicitly part of the pattern.
correct. the bash specification says that when /.
is part of your pattern (or ^.
), it will always match dotfiles, even if options.dot
is false.
from micromatch.
correct.
Okey, got it. But issue is a bit another, see my last post. And see this example it may clear it a bit
function matchPlugin (patterns, options) {
var matcher = require('is-match')
var isMatch = matcher(patterns, options)
return function matchPlugin (app) {
return function (file) {
var fp = file.path
// this little hack is needed, for example:
// pattern: foo/bar/**
// -> foo/bar/baz
// -> foo/bar/baz/qux.js
// -> foo/bar/
// -> foo/bar -> fails, so we tweak it with this hack
if (file.stat.isDirectory()) {
fp = file.path.charAt(-1) === '/' ? file.path.slice(0, -1) : file.path
fp = fp + '/'
}
if (!file.exclude && !isMatch(fp)) file.exclude = true
}
}
}
Btw, is the refactor
is near to push to github? :)
from micromatch.
Did you notice you're using .makeRe
on the filepath, not on the pattern?
is the refactor is near to push to github? :)
maybe, I'll look.
from micromatch.
@jonschlinkert from @tunnckoCore's first post, it seems there actually is a bug:
mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/**'); // => true; should be false
from micromatch.
yeah that's what I was thinking as well. but I hadn't had a chance to check. Is it only when the path is absolute?
from micromatch.
@MartinKolarik yea, but that's another bug, maybe we should separate them in separate issues.
I'm talking for another.
var micromatch = require('micromatch')
var isMatch = micromatch.matcher('foo/bar/**')
console.log(isMatch('foo/bar')) // => false, i think it make sense to pass?
console.log(isMatch('foo/bar/')) // => true
console.log(isMatch('foo/bar/baz')) // => true
console.log(isMatch('foo/bar/baz/fez')) // => true
console.log(isMatch('foo/bar/baz/qux.js')) // => true
Is it only when the path is absolute?
Hmm, I thought answer was yes
, but huh.
var micromatch = require('micromatch')
console.log(micromatch.isMatch('/aaa/bbb/.git', '/aaa/bbb/**', {dot: true}))
console.log(micromatch.isMatch('/aaa/bbb/.git', '/aaa/bbb/**', {dot: false}))
console.log(micromatch.isMatch('aaa/bbb/.git', 'aaa/bbb/**', {dot: true}))
console.log(micromatch.isMatch('aaa/bbb/.git', 'aaa/bbb/**', {dot: false}))
obviously, no.
from micromatch.
maybe we should separate them in separate issues.
let's do that please. Also try to just use the minimum reduced use case to illustrate the bug. thanks
from micromatch.
@MartinKolarik yea, but that's another bug, maybe we should separate them in separate issues.
I see. From your original post, I thought this was the problem you were reporting 😄
console.log(isMatch('foo/bar')) // => false, i think it make sense to pass?
I that case, bar
might be a file in foo
directory, and definitely shouldn't match.
from micromatch.
closing this issue since we're splitting out
from micromatch.
Related Issues (20)
- Can't match string with leading dot HOT 3
- extglob Denial of service HOT 4
- Non-filepaths matchs HOT 3
- SyntaxError: Invalid or unexpected token when running from Jest HOT 1
- 'Or' functionality broken (using |)
- Proper docs for windows option??
- Add a way to generate a glob from a file name HOT 1
- Basename breaks matching complex pattern HOT 2
- Will micromatch gradually phase out CJS support instead of abruptly (cf multimatch)? HOT 2
- Documentation incomplete for `scan`
- Alternatives in extglobs not matching correctly? HOT 5
- micromatch('.prettierrc.json', '**/*.json') => false HOT 3
- Image for sponsorships
- [BUG] Vulnerabilities Found in Micromatch and Braces HOT 2
- `micromatch.not` returns nothing if empty pattern list provided
- [BUG] Vulnerabilities Found in Micromatch and Braces HOT 38
- gitIgnore and negation patterns - not following gitIgnore specs HOT 5
- Question: Globstar and trailing slashes
- Inefficient Regular Expression Complexity vulnerability with High severity found HOT 5
- Negation style ignores dot option?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micromatch.