Skip to content

Commit 218225e

Browse files
committed
fix(delta-upgrade): normalize extractSha256 output to lowercase
Bun.CryptoHasher.digest('hex') always returns lowercase hex, but SHA256_DIGEST_PATTERN with the /i flag could capture uppercase from GitHub asset digests. Normalize to lowercase to ensure comparison always succeeds regardless of upstream casing.
1 parent 3d367ee commit 218225e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/lib/delta-upgrade.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export function extractSha256(asset: GitHubAsset): string | null {
150150
return null;
151151
}
152152
const match = SHA256_DIGEST_PATTERN.exec(asset.digest);
153-
return match ? (match[1] ?? null) : null;
153+
// Normalize to lowercase — Bun.CryptoHasher.digest("hex") returns lowercase
154+
return match ? (match[1]?.toLowerCase() ?? null) : null;
154155
}
155156

156157
/**

test/lib/delta-upgrade.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ describe("extractSha256", () => {
151151
expect(extractSha256(asset)).toBeNull();
152152
});
153153

154-
test("handles uppercase hex", () => {
154+
test("normalizes uppercase hex to lowercase", () => {
155155
const asset = makeAsset({ digest: "sha256:ABCDEF0123456789" });
156-
expect(extractSha256(asset)).toBe("ABCDEF0123456789");
156+
expect(extractSha256(asset)).toBe("abcdef0123456789");
157157
});
158158

159159
test("handles mixed case prefix", () => {

0 commit comments

Comments
 (0)