From 233624b6ff05c669979de0c0b21d0c82f5c47875 Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 15 Apr 2024 17:03:44 +0500 Subject: [PATCH] fix(which/windows): ignore file extension case (#10102) * 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 fb3ad51de71bbc23aa50801b2041f216f8eb5a01. * add test --------- Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com> --- src/which.zig | 2 +- test/js/bun/util/which.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/which.zig b/src/which.zig index 3295877f2fd7f9..5aaaa8cd0f97e8 100644 --- a/src/which.zig +++ b/src/which.zig @@ -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; } diff --git a/test/js/bun/util/which.test.ts b/test/js/bun/util/which.test.ts index ffd02386a31fab..edb4670e32a2b8 100644 --- a/test/js/bun/util/which.test.ts +++ b/test/js/bun/util/which.test.ts @@ -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, "../");