We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c53bce commit bdbfa9aCopy full SHA for bdbfa9a
1 file changed
frontend/src/ts/utils/strings.ts
@@ -320,10 +320,17 @@ export function areCharactersVisuallyEqual(
320
}
321
322
export function toHex(buffer: ArrayBuffer): string {
323
- if (Uint8Array.prototype.toHex !== undefined) {
324
- return new Uint8Array(buffer).toHex();
+ const u8 = new Uint8Array(buffer);
+
325
+ // Use native toHex if available (modern browsers / future runtimes)
326
+ if (
327
+ "toHex" in u8 &&
328
+ typeof (u8 as { toHex?: unknown }).toHex === "function"
329
+ ) {
330
+ return (u8 as unknown as { toHex(): string }).toHex();
331
- const hashArray = Array.from(new Uint8Array(buffer));
332
333
+ const hashArray = Array.from(u8);
334
const hashHex = hashArray
335
.map((b) => b.toString(16).padStart(2, "0"))
336
.join("");
0 commit comments