Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions frontend/src/ts/utils/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,17 @@ export function areCharactersVisuallyEqual(
}

export function toHex(buffer: ArrayBuffer): string {
if (Uint8Array.prototype.toHex !== undefined) {
return new Uint8Array(buffer).toHex();
const u8 = new Uint8Array(buffer);

// Use native toHex if available (modern browsers / future runtimes)
if (
"toHex" in u8 &&
typeof (u8 as { toHex?: unknown }).toHex === "function"
) {
return (u8 as unknown as { toHex(): string }).toHex();
}
const hashArray = Array.from(new Uint8Array(buffer));

const hashArray = Array.from(u8);
const hashHex = hashArray
.map((b) => b.toString(16).padStart(2, "0"))
.join("");
Expand Down
Loading