glob-match
glob-match copied to clipboard
fix: pattern with wildcard and globstar fails to match
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/"));