Skip to content

Commit 26455ee

Browse files
committed
test: add comprehensive ./ prefix pattern tests
- Add 48 tests for patterns starting with ./ - Fix ./ pattern returning empty (now returns ['.']) - Fix empty string cwd handling to use process.cwd() - Test ./ prefix transparency, dotRelative interaction, mark, nodir - Document known limitation: path normalization not implemented
1 parent ee7af6c commit 26455ee

3 files changed

Lines changed: 422 additions & 1 deletion

File tree

js/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ function toNativeOptions(options?: GlobOptions): NativeGlobOptions {
210210
}
211211

212212
return {
213-
cwd: rest.cwd ?? process.cwd(),
213+
// Use process.cwd() if cwd is undefined, null, or empty string
214+
cwd: rest.cwd || process.cwd(),
214215
...rest,
215216
ignore: nativeIgnore,
216217
}

src/pattern.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,12 @@ pub fn preprocess_pattern(pattern: &str) -> String {
10711071
result = result[2..].to_string();
10721072
}
10731073

1074+
// If the pattern was just "./" (or ".//" etc), it becomes empty after stripping.
1075+
// Treat this as "." which matches the current directory.
1076+
if result.is_empty() && pattern.starts_with("./") {
1077+
return ".".to_string();
1078+
}
1079+
10741080
result
10751081
}
10761082

0 commit comments

Comments
 (0)