mirror of
https://github.com/swc-project/swc.git
synced 2025-01-02 10:37:56 +03:00
15 lines
446 B
TypeScript
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');
|
||
|
}
|
||
|
}
|