Skip to content

The open source coding agent.

TypeScript

fix(util): checksum defensiveness

Adamd1a4295a3284
diff --git a/packages/util/src/encode.ts b/packages/util/src/encode.ts
index fc1f783bf27..bf6fa75dc28 100644
--- a/packages/util/src/encode.ts
+++ b/packages/util/src/encode.ts
@@ -20,6 +20,7 @@ export async function hash(content: string, algorithm = "SHA-256"): Promise<stri
}
export function checksum(content: string): string {
+ if (!content) return ""
let hash = 0x811c9dc5
for (let i = 0; i < content.length; i++) {
hash ^= content.charCodeAt(i)