diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding/_utils.ts')
-rw-r--r-- | ext/node/polyfills/internal_binding/_utils.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/node/polyfills/internal_binding/_utils.ts b/ext/node/polyfills/internal_binding/_utils.ts index a773f0a9c..74dc3cbcd 100644 --- a/ext/node/polyfills/internal_binding/_utils.ts +++ b/ext/node/polyfills/internal_binding/_utils.ts @@ -18,9 +18,13 @@ export function asciiToBytes(str: string) { } export function base64ToBytes(str: string) { - str = base64clean(str); - str = str.replaceAll("-", "+").replaceAll("_", "/"); - return forgivingBase64Decode(str); + try { + return forgivingBase64Decode(str); + } catch { + str = base64clean(str); + str = str.replaceAll("-", "+").replaceAll("_", "/"); + return forgivingBase64Decode(str); + } } const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; |