swc/bundler/tests/.cache/deno/02fec2e21e7ad66e6023abe2223435a89f34b31b.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

22 lines
701 B
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isUUID.ts
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
/**
* @ignore
*/
const uuid = {
3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
};
export const isUUID = (str: string, version: 3 | 4 | 5 | 'all' = 'all') => {
assertString(str);
const pattern = (uuid as any)[version];
return pattern && pattern.test(str);
};