mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 07:02:28 +03:00
21 lines
415 B
TypeScript
21 lines
415 B
TypeScript
// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isBase32.ts
|
|
|
|
|
|
// @ts-ignore allowing typedoc to build
|
|
import { assertString } from '../helpers/assertString.ts';
|
|
|
|
/**
|
|
* @ignore
|
|
*/
|
|
const base32 = /^[A-Z2-7]+=*$/;
|
|
|
|
export const isBase32 = (str: string) => {
|
|
assertString(str);
|
|
|
|
const len = str.length;
|
|
if (len > 0 && len % 8 === 0 && base32.test(str)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|