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

dot in testString as pathname or filename, can't match #41

Open
Alucelx opened this issue May 14, 2021 · 0 comments
Open

dot in testString as pathname or filename, can't match #41

Alucelx opened this issue May 14, 2021 · 0 comments

Comments

@Alucelx
Copy link

Alucelx commented May 14, 2021

use case is that, first new a matcher in anymatch, 2nd use the matcher to match teststring.
if teststring is path string and some path or file has dot symbol, will match failed, the example at flow:

const matcher = anymatch(["**/node_modules/**"]);
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
const result = matcher(str); // false
const result2 = matcher(str2); // false

then i review the source code of anymatch, and i found a solution:

const matcher = anymatch(["**/node_modules/**"], null, {dot: true});
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
const result = matcher(str); // true  // ts checker error
const result2 = matcher(str2); // true // ts checker error

but if this code is in ts, the ide tell me an error of checker at the line that match the test string, because anymatch/index.d.ts dosn't have this override, so we should add a comment to tell checker to ignore this line.

const matcher = anymatch(["**/node_modules/**"], null, {dot: true});
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
// @ts-ignore
const result = matcher(str); // true
// @ts-ignore
const result2 = matcher(str2); // true
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

1 participant