GithubHelp home page GithubHelp logo

davidchambers / base64.js Goto Github PK

View Code? Open in Web Editor NEW
487.0 487.0 220.0 97 KB

Polyfill for browsers that don't provide window.btoa and window.atob

License: Other

JavaScript 77.71% Shell 1.15% Makefile 21.14%

base64.js's People

Contributors

bbboy01 avatar davidchambers avatar emmy41124 avatar koichik avatar michaelficarra avatar mouvedia avatar sheetjsdev avatar skim1420 avatar sno2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

base64.js's Issues

Adobe ExtendScript errors with self and certain regular expressions

We were addressing an unexpected issue about running in Adobe ExtendScript SheetJS/sheetjs#603.
It's the scripting runtime for Adobe products, and it claims to be "extended" ECMAScript.

After some digging, we found two issues:

  1. self is not available in extendscript and the object assignment assumes self is defined:
  var object = typeof exports != 'undefined' ? exports : self; // #8: web workers
  // when exports and self are both undefined, this line fails thanks to the unguarded assignment 

The indirect eval trick (1,eval)('this') appeared to work:

  var object = typeof exports != 'undefined' ? exports : typeof self != 'undefined' ? self : (1,eval)('this')
  1. Regular expression literals starting with = are problematic:

screen shot 2017-03-23 at 19 32 44

I believe the fix here is to turn /=+$/ into a RegExp call: new RegExp("=+$")

Add standard license

It would be great if this was released up Apache2 so it could more easily be added to other open-source projects.

How to handle InvalidCharacterError?

I started using this library as an alternative to atob in Safari. It handles more cases than the native implementation, but I still run into this error occasionally. It doesn't tell me which character is causing the problem, and I don't know how to handle it. What can be done to make atob more robust?

Allow integers as input

At the moment if you pass an integer to the polyfill it will error because doing charAt() on an integer isn't valid.

I know the docs for the native version of btoa state that the input should be a string but both Chrome & Firefox allow integers to be used without erroring so I think not erroring on integers would be in-line with how someone would expect the polyfill to work.

assigning this does not work in all environments

Hi,

the code:

var object = typeof exports != 'undefined' ? exports : this; // #8: web workers
  var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

does rely on the fact, that this is always referring to the global scope; but when somehow base64 is evaluated in other contexts, this can be undefined and thus the subsequent assigning of btoa is failing, because object itself is then undefined.

When using the grunt usemin task for production, we get this error in the production build. There is no easy way around it; maybe one could check simply, whether atob btoa itself is a function, when exports is undefined.

Euro sign issue.

Hy. I have encoded a string that contains a price with EURO SIGN in it.

Original text was:
Inclusief eenmalige korting van € 130 & verlaagd vastrecht.

After decode the text is:
Inclusief eenmalige korting van � 130 & verlaagd vastrecht.

As you see the euro sign is missing

Thanks

Merge error: conflicting capitalizations

Copied from: mainmatter/ember-simple-auth#766
I'm running OS X El Capitan 10.11.1
It seems to be related to the base64 install

Future versions of Ember CLI will not support v5.0.0. Please update to Node 0.12 or io.js.
version: 1.13.8
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
Merge error: conflicting capitalizations:
base64 in /Users/jarednance/Code/ember-simple-auth/tmp/broccoli_merge_trees-input_base_path-TFvTJRgu.tmp/8
Base64 in /Users/jarednance/Code/ember-simple-auth/tmp/broccoli_merge_trees-input_base_path-TFvTJRgu.tmp/34
Remove one of the files and re-add it with matching capitalization.
We are strict about this to avoid divergent behavior between case-insensitive Mac/Windows and case-sensitive Linux.
Error: Merge error: conflicting capitalizations:
base64 in /Users/jarednance/Code/ember-simple-auth/tmp/broccoli_merge_trees-input_base_path-TFvTJRgu.tmp/8
Base64 in /Users/jarednance/Code/ember-simple-auth/tmp/broccoli_merge_trees-input_base_path-TFvTJRgu.tmp/34
Remove one of the files and re-add it with matching capitalization.
We are strict about this to avoid divergent behavior between case-insensitive Mac/Windows and case-sensitive Linux.
    at mergeRelativePath (/Users/jarednance/Code/ember-simple-auth/node_modules/ember-cli/node_modules/broccoli-merge-trees/index.js:59:19)
    at BroccoliMergeTrees.build (/Users/jarednance/Code/ember-simple-auth/node_modules/ember-cli/node_modules/broccoli-merge-trees/index.js:26:3)
    at /Users/jarednance/Code/ember-simple-auth/node_modules/broccoli-plugin/read_compat.js:61:34
    at lib$rsvp$$internal$$tryCatch (/Users/jarednance/Code/ember-simple-auth/node_modules/rsvp/dist/rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/jarednance/Code/ember-simple-auth/node_modules/rsvp/dist/rsvp.js:505:17)
    at lib$rsvp$$internal$$publish (/Users/jarednance/Code/ember-simple-auth/node_modules/rsvp/dist/rsvp.js:476:11)
    at lib$rsvp$asap$$flush (/Users/jarednance/Code/ember-simple-auth/node_modules/rsvp/dist/rsvp.js:1198:9)
    at doNTCallback0 (node.js:428:9)
    at process._tickCallback (node.js:357:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.