Skip to content

Commit

Permalink
Update angular-base64.js
Browse files Browse the repository at this point in the history
Automatically pad out decode string size with '=' or '==' for compatibility with encoders which do not automatically add padding.

See: ninjatronic#13
  • Loading branch information
ravenscar committed Nov 13, 2015
1 parent 681f305 commit dc3af23
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions angular-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,18 @@
function decode(s) {
// convert to string
s = "" + s;
var pads, i, b10;
var imax = s.length;
var pads, i, b10, imax;

if ((s.length % 4) === 1) {
s = s + PADCHAR;
}

if ((s.length % 4) === 2) {
s = s + PADCHAR + PADCHAR;
}

imax = s.length;

if (imax == 0) {
return s;
}
Expand Down

0 comments on commit dc3af23

Please sign in to comment.