mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
24 lines
549 B
TypeScript
24 lines
549 B
TypeScript
// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isJWT.ts
|
|
|
|
|
|
// @ts-ignore allowing typedoc to build
|
|
import { assertString } from '../helpers/assertString.ts';
|
|
// @ts-ignore allowing typedoc to build
|
|
import { isBase64 } from './isBase64.ts';
|
|
|
|
export const isJWT = (str: string) => {
|
|
assertString(str);
|
|
|
|
const dotSplit = str.split('.');
|
|
const len = dotSplit.length;
|
|
|
|
if (len > 3 || len < 2) {
|
|
return false;
|
|
}
|
|
|
|
return dotSplit.reduce(
|
|
(acc, currElem) => acc && isBase64(currElem, { urlSafe: true }),
|
|
true
|
|
);
|
|
};
|