angular-token-auth icon indicating copy to clipboard operation
angular-token-auth copied to clipboard

Decoder should replace all

Open michaelkantor opened this issue 8 years ago • 0 comments

I'm not a user, but I did notice and copy your url_base64_decoder for a project of my own. I've noticed the following issue with it which you may want to fix:

https://github.com/auth0-blog/angular-token-auth/blob/master/auth.client.js#L5:

var output = str.replace('-', '+').replace('_', '/');

should in fact be doing a replace All:

const reg1 = new RegExp("_", "g");
const reg2 = new RegExp("-", "g");
let output = str.replace(reg2, '+').replace(reg1, '/');

Clarification: There is nothing limiting a string to a single "_" or "-" character.

michaelkantor avatar Jun 28 '17 19:06 michaelkantor