davidchambers / base64.js Goto Github PK
View Code? Open in Web Editor NEWPolyfill for browsers that don't provide window.btoa and window.atob
License: Other
Polyfill for browsers that don't provide window.btoa and window.atob
License: Other
Module is currently broken when used with browserify.
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:
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')
=
are problematic:I believe the fix here is to turn /=+$/
into a RegExp call: new RegExp("=+$")
It would be great if this was released up Apache2 so it could more easily be added to other open-source projects.
I get that error when using Base64.js in SuiteScript v2
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?
As a source of inspiration, https://github.com/beatgammit/base64-js may be used...
What do you think about adding support for the base64url encoding to this package? The only difference between base64url and base64 is the encoding of the 62nd and 63rd alphabet characters (https://tools.ietf.org/html/rfc4648#page-7). It seems a shame to do a whole separate pass over the string just to make this small change (as is done here https://github.com/joaquimserafim/base64-url/blob/master/index.js#L10).
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.
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.
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
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)
We can't redistribute based on WTFPL. Would you be open to changing the license to any of the [http://apache.org/licenses/LICENSE-2.0](Apache 2), http://opensource.org/licenses/mit-license.php, http://opensource.org/licenses/bsd-license.php, etc?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.