Skip to content

Commit

Permalink
Fix Illegal invocation error when using aliased window.btoa or window…
Browse files Browse the repository at this point in the history
….atob
  • Loading branch information
ross-pfahler committed Feb 4, 2014
1 parent bdd125b commit cc2a837
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ InvalidCharacterError.prototype.name = 'InvalidCharacterError';

// encoder
// [https://gist.github.com/999166] by [https://github.com/nignag]
base64.btoa = window.btoa || function (input) {
base64.btoa = window.btoa ? function(input) { return window.btoa(input); } : function (input) {
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars, output = '';
Expand All @@ -31,7 +31,7 @@ base64.btoa = window.btoa || function (input) {

// decoder
// [https://gist.github.com/1020396] by [https://github.com/atk]
base64.atob = window.atob || function (input) {
base64.atob = window.atob ? function(input) { return window.atob(input); } : function (input) {
input = input.replace(/=+$/, '')
if (input.length % 4 == 1) {
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
Expand Down
6 changes: 3 additions & 3 deletions base64.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Base64",
"version": "0.3.2",
"version": "0.3.3",
"description": "Base64 encoding and decoding",
"author": "David Chambers <[email protected]>",
"main": "./base64.js",
Expand Down

0 comments on commit cc2a837

Please sign in to comment.