Skip to content

fix: pattern with wildcard and globstar fails to match #18

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

shulaoda
Copy link

Related to PR #15

Due to some reasons, I have to open a new PR.

Benchmark

const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
const GLOB: &'static str = "some/**/needle.txt";
Before                   time:   [184.81 ns 186.20 ns 187.86 ns]
After                    time:   [104.72 ns 104.95 ns 105.27 ns]

Add new test cases

assert!(glob_match("/**/*a", "/a/a"));
assert!(glob_match("**/*.js", "a/b.c/c.js"));
assert!(glob_match("**/**/*.js", "a/b.c/c.js"));
assert!(glob_match("a/**/*.d", "a/b/c.d"));
assert!(glob_match("a/**/*.d", "a/.b/c.d"));

assert!(glob_match("**/*/**", "a/b/c"));
assert!(glob_match("**/*/c.js", "a/b/c.js"));

assert!(glob_match("**/**.txt.js", "/foo/bar.txt.js"));

Change some test cases

assert!(!glob_match("a/**/*", "a/"));
assert!(!glob_match("a/**/**/*", "a/"));
assert!(!glob_match("a/**/**/**/*", "a/"));

to

assert!(glob_match("a/**/*", "a/"));
assert!(glob_match("a/**/**/*", "a/"));
assert!(glob_match("a/**/**/**/*", "a/"));

@shakyShane
Copy link

I just ran into this, I'll have to switch to regular glob instead which is a shame :)

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

Successfully merging this pull request may close these issues.

2 participants