mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
perf: optimize Buffer.from("base64") for forgiving-base64 conforming input (#24346)
This commit is contained in:
parent
6da87450ed
commit
2549e5154c
@ -18,9 +18,13 @@ export function asciiToBytes(str: string) {
|
||||
}
|
||||
|
||||
export function base64ToBytes(str: string) {
|
||||
try {
|
||||
return forgivingBase64Decode(str);
|
||||
} catch {
|
||||
str = base64clean(str);
|
||||
str = str.replaceAll("-", "+").replaceAll("_", "/");
|
||||
return forgivingBase64Decode(str);
|
||||
}
|
||||
}
|
||||
|
||||
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
||||
|
Loading…
Reference in New Issue
Block a user