Fix utf8ToBytes in firefox extension context

This commit is contained in:
Paul Miller 2023-06-02 13:57:46 +00:00
parent c6b4aadafb
commit b281167e8d
No known key found for this signature in database
GPG Key ID: 697079DA6878B89B

@ -140,7 +140,7 @@ declare const TextEncoder: any;
*/ */
export function utf8ToBytes(str: string): Uint8Array { export function utf8ToBytes(str: string): Uint8Array {
if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`); if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
return new TextEncoder().encode(str); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
} }
// Bit operations // Bit operations