Skip to content

Instantly share code, notes, and snippets.

@byurhannurula
Created November 4, 2021 08:33
Show Gist options
  • Save byurhannurula/a76d8ef2e2d25c5e0f9d30d945c8e32a to your computer and use it in GitHub Desktop.
Save byurhannurula/a76d8ef2e2d25c5e0f9d30d945c8e32a to your computer and use it in GitHub Desktop.
Check string if it's a JWT token
const JWT_PATTERN = "(^[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*\$)";
function isJWT(data) {
return new RegExp(JWT_PATTERN).matches(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment