swc/bundler/tests/.cache/untrusted/f0f2dea4a5609fd5ea2df8fd2884e1cd43b1ef18.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

15 lines
446 B
TypeScript

// Loaded from https://raw.githubusercontent.com/aricart/tweetnacl-deno/import-type-fixes/src/validate.ts
export function validateBase64(s: string) {
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)) {
throw new TypeError('invalid base64 string');
}
}
export function validateHex(s: string) {
if (!/^(?:[A-Fa-f0-9]{2})+$/.test(s)) {
throw new TypeError('invalid hex string');
}
}