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

Matching specific file is not found when pattern contains parentheses #223

Closed
zrh122 opened this issue Aug 19, 2019 · 4 comments
Closed
Assignees
Milestone

Comments

@zrh122
Copy link

zrh122 commented Aug 19, 2019

Environment

  • OS Version: Windows 7
  • Node.js Version: v10.16.2

Actual behavior

two results is not same

Expected behavior

two results should be the same

Steps to reproduce

create directory and file, and run the code

Code sample

directory structure:

├── tmp(asd)
    └── a.tmp

from above directory, run script:

const fg = require('fast-glob');
const paths = fg.sync('./tmp\\(asd\\)/a.tmp');
console.log(paths); // []
const paths1 = fg.sync('./tmp\\(asd\\)/*');
console.log(paths1); // ['./tmp(asd)/a.tmp']
@mrmlnc
Copy link
Owner

mrmlnc commented Sep 4, 2019

So, after some research we have a three ways to solve this problem:

  • Check that the pattern is a static pattern and then strip escaped characters. In fact, this is a modification of user input, which can lead to problems.
  • Check that the pattern has escaped characters and then move him to dynamic patterns. Looks good for me, but it can lead to loss of performance (only for patterns with escaped characters). Just add extra checks for the isDynamicPattern function.
  • Do not escaped characters for filepath's (non glob pattern's). It is required that the user understood the difference, which is difficult and will still lead to problems.

And… right now i prefer the second solution.

@mrmlnc
Copy link
Owner

mrmlnc commented Sep 4, 2019

We have a some problem here with pattern file-\\(suffix\\).md.

{
  dynamic: true,
  positive: [ 'file-\\(suffix\\).md' ],
  negative: [],
  base: 'file-', // by glob-parent
  patterns: [ 'file-\\(suffix\\).md' ]
}

gulpjs/glob-parent#12
https://github.com/gulpjs/glob-parent/blob/d4975484222bb811c02dc2dc268ea48e2fb7ae6d/test/index.test.js#L73

@mrmlnc
Copy link
Owner

mrmlnc commented Sep 22, 2019

Waiting for DefinitelyTyped/DefinitelyTyped#38521

@mrmlnc
Copy link
Owner

mrmlnc commented Sep 26, 2019

Will be fixed with fast-glob@3.1.0 (#231).

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

No branches or pull requests

2 participants