Browse Source

Fix regression: Old browser support

master
Feross Aboukhadijeh 11 years ago
parent
commit
ac3efd3a29
  1. 10
      lib/b64.js

10
lib/b64.js

@ -1,9 +1,12 @@
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
;(function (exports) {
'use strict';
var Arr = (typeof Uint8Array !== 'undefined')
? Uint8Array
: Array
var ZERO = '0'.charCodeAt(0)
var PLUS = '+'.charCodeAt(0)
var SLASH = '/'.charCodeAt(0)
@ -40,10 +43,10 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
var len = b64.length
placeHolders = '=' === b64[len - 2] ? 2 : '=' === b64[len - 1] ? 1 : 0
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
// base64 is 4/3 + up to two characters of the original data
arr = new Uint8Array(b64.length * 3 / 4 - placeHolders);
arr = new Arr(b64.length * 3 / 4 - placeHolders);
// if there are placeholders, only get up to the last complete 4 chars
@ -118,6 +121,5 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
module.exports.toByteArray = b64ToByteArray;
module.exports.fromByteArray = uint8ToBase64;
module.exports.lookup = lookup
}());

Loading…
Cancel
Save