Skip to content
Snippets Groups Projects
Commit b4749769 authored by okoriko's avatar okoriko
Browse files

Fix javascript JWT regexp check

parent ce845575
Branches
Tags
No related merge requests found
......@@ -65,7 +65,7 @@ var MetabaseUtils = {
},
isJWT(string) {
return typeof string === "string" && /^[A-Za-z0-9]+\.[A-Za-z0-9]+\.[A-Za-z0-9_-]+$/.test(string);
return typeof string === "string" && /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(string);
},
validEmail: function(email) {
......
......@@ -79,6 +79,12 @@ describe('utils', () => {
expect(MetabaseUtils.isEmpty(" ")).toEqual(true);
});
});
describe("isJWT", () => {
it("should allow for JWT tokens with dashes", () => {
expect(MetabaseUtils.isJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJhbXMiOnsicGFyYW0xIjoidGVzdCIsInBhcmFtMiI6ImFiIiwicGFyYW0zIjoiMjAwMC0wMC0wMFQwMDowMDowMCswMDowMCIsInBhcmFtNCI6Iu-8iO-8iSJ9LCJyZXNvdXJjZSI6eyJkYXNoYm9hcmQiOjB9fQ.wsNWliHJNwJBv_hx0sPo1EGY0nATdgEa31TM1AYotIA")).toEqual(true);
});
});
});
function shuffle(a) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment