Skip to content

Commit 66c9e78

Browse files
committed
Fix multiple occurences of - or _ in tokens
String replacements replaced only the first occurence of `-` or `_` in tokens for base64 decoding, which meant that there was a base64 decode error if more than one of either was present in the base64url format. Use regexps in replacement instead to get a global match.
1 parent 56f41e9 commit 66c9e78

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

js/jwt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ window.hextorstr = function (c) {
1111

1212
//this is used to parse base64
1313
function url_base64_decode(str) {
14-
var output = str.replace('-', '+').replace('_', '/');
14+
var output = str.replace(/-/g, '+').replace(/_/g, '/');
1515
switch (output.length % 4) {
1616
case 0:
1717
break;

0 commit comments

Comments
 (0)