Skip to content

Commit

Permalink
fix(which/windows): ignore file extension case (#10102)
Browse files Browse the repository at this point in the history
* fix(which/windows): ignore file extension case

* feat(which): add test for `endsWithExtension` fun

* Revert "feat(which): add test for `endsWithExtension` fun"

This reverts commit fb3ad51.

* add test

---------

Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
  • Loading branch information
SunsetTechuila and gvilums authored Apr 15, 2024
1 parent fdcc844 commit 233624b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/which.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn endsWithExtension(str: []const u8) bool {
const file_ext = str[str.len - 3 ..];
inline for (win_extensions) |ext| {
comptime bun.assert(ext.len == 3);
if (bun.strings.eqlComptimeCheckLenWithType(u8, file_ext, ext, false)) return true;
if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(file_ext, ext)) return true;
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions test/js/bun/util/which.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if (isWindows) {
test("which", () => {
expect(which("cmd")).toBe("C:\\Windows\\system32\\cmd.exe");
expect(which("cmd.exe")).toBe("C:\\Windows\\system32\\cmd.exe");
expect(which("cmd.EXE")).toBe("C:\\Windows\\system32\\cmd.EXE");
expect(which("cmd.bat")).toBe(null);
const exe = basename(process.execPath);
const dir = join(process.execPath, "../");
Expand Down

0 comments on commit 233624b

Please sign in to comment.