mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-24 01:11:34 +01:00
Add workaround for #114227
This commit is contained in:
@@ -10,7 +10,7 @@ export async function sha1Hex(str: string): Promise<string> {
|
||||
|
||||
// Prefer to use browser's crypto module
|
||||
if (globalThis?.crypto?.subtle) {
|
||||
const hash = await globalThis.crypto.subtle.digest({ name: 'sha-1' }, VSBuffer.fromString(str).buffer);
|
||||
const hash = await globalThis.crypto.subtle.digest({ name: 'sha-1' }, VSBuffer.fromString(str, { dontUseNodeBuffer: true }).buffer);
|
||||
|
||||
return toHexString(hash);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,9 @@ export class VSBuffer {
|
||||
return new VSBuffer(actual);
|
||||
}
|
||||
|
||||
static fromString(source: string): VSBuffer {
|
||||
if (hasBuffer) {
|
||||
static fromString(source: string, options?: { dontUseNodeBuffer?: boolean; }): VSBuffer {
|
||||
const dontUseNodeBuffer = options?.dontUseNodeBuffer || false;
|
||||
if (!dontUseNodeBuffer && hasBuffer) {
|
||||
return new VSBuffer(Buffer.from(source));
|
||||
} else if (hasTextEncoder) {
|
||||
if (!textEncoder) {
|
||||
|
||||
Reference in New Issue
Block a user