Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globstar option has no affect for patterns without prefix #20

Closed
mrmlnc opened this issue Jun 9, 2019 · 5 comments
Closed

globstar option has no affect for patterns without prefix #20

mrmlnc opened this issue Jun 9, 2019 · 5 comments

Comments

@mrmlnc
Copy link
Contributor

mrmlnc commented Jun 9, 2019

Environment

  • Windows 10 (1903)
  • Node.js 12.3.1
  • picomatch 2.0.7

Actual behaviour

const a = mm.isMatch('a/b/c', '**', { noglobstar: false });
const b = mm.isMatch('a/b/c', '**', { noglobstar: true });

console.log(a, b); // true true

const c = mm.isMatch('a/b/c', 'a/**', { noglobstar: false });
const d = mm.isMatch('a/b/c', 'a/**', { noglobstar: true });

console.log(c, d); // true false

RegExp's:

a: /^(?:(?!\.)(?:(?:(?!(?:^|[\\\/])\.).)*?)[\\\/]?)$/
b: /^(?:(?!\.)(?:(?:(?!(?:^|[\\\/])\.).)*?)[\\\/]?)$/
c: /^(?:a(?:[\\\/](?!\.)(?:(?:(?!(?:^|[\\\/])\.).)*?)|$))$/
d: /^(?:a[\\\/](?!\.)[^\\\/]*?[\\\/]?)$/

Expected behaviour

For case b and d, I expect false based on the globstar option description and bash shopt -s globstar.

Disable support for matching nested directories with globstars (**).

console.log(a, b); // true false
console.log(c, d); // true false
@mrmlnc mrmlnc assigned mrmlnc and unassigned mrmlnc Jun 9, 2019
@mrmlnc
Copy link
Contributor Author

mrmlnc commented Jun 9, 2019

Most likely this is related to fastpaths functionality.

parse.fastpaths = (input, options) => {
	// …
	const globstar = (opts) => {
		return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
	};
	// …
}

@jonschlinkert
Copy link
Member

Most likely this is related to fastpaths functionality.

thanks for the debugging. Did you try disabling fastpaths to see if it works? I think I forgot about that rule when I added support for fastpaths. A fix should be pretty easy if that is indeed what's causing the issue.

@mrmlnc
Copy link
Contributor Author

mrmlnc commented Jun 9, 2019

Yeap, works correctly with fastpaths: false:

a: /^(?:(?:(?:(?!(?:^|[\\\/])\.).)*?))$/
b: /^(?:(?!\.)[^\\\/]*?[\\\/]?)$/
c: /^(?:a(?:[\\\/](?!\.)(?:(?:(?!(?:^|[\\\/])\.).)*?)|$))$/
d: /^(?:a[\\\/](?!\.)[^\\\/]*?[\\\/]?)$/

@jonschlinkert
Copy link
Member

jonschlinkert commented Jun 9, 2019

Yeap, works correctly with fastpaths: false:

great, thanks for checking!

I'll get a fix pushed up asap

@mrmlnc
Copy link
Contributor Author

mrmlnc commented Jun 9, 2019

Thanks 🎉 Don't worry, it's not urgent :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants