浏览代码

fix(util): checksum defensiveness

Adam 8 月之前
父节点
当前提交
03733b0505
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      packages/util/src/encode.ts

+ 2 - 2
packages/util/src/encode.ts

@@ -19,8 +19,8 @@ export async function hash(content: string, algorithm = "SHA-256"): Promise<stri
   return hashHex
   return hashHex
 }
 }
 
 
-export function checksum(content: string): string {
-  if (!content) return ""
+export function checksum(content: string): string | undefined {
+  if (!content) return undefined
   let hash = 0x811c9dc5
   let hash = 0x811c9dc5
   for (let i = 0; i < content.length; i++) {
   for (let i = 0; i < content.length; i++) {
     hash ^= content.charCodeAt(i)
     hash ^= content.charCodeAt(i)