mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Changing btoa ponyfill to improve testing
This commit is contained in:
+6
-6
@@ -4,12 +4,12 @@
|
||||
|
||||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
function InvalidCharacterError(message) {
|
||||
this.message = message;
|
||||
function E() {
|
||||
this.message = 'String contains an invalid character';
|
||||
}
|
||||
InvalidCharacterError.prototype = new Error;
|
||||
InvalidCharacterError.prototype.code = 5;
|
||||
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
||||
E.prototype = new Error;
|
||||
E.prototype.code = 5;
|
||||
E.prototype.name = 'InvalidCharacterError';
|
||||
|
||||
function btoa(input) {
|
||||
var str = String(input);
|
||||
@@ -26,7 +26,7 @@ function btoa(input) {
|
||||
) {
|
||||
charCode = str.charCodeAt(idx += 3 / 4);
|
||||
if (charCode > 0xFF) {
|
||||
throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');
|
||||
throw new E();
|
||||
}
|
||||
block = block << 8 | charCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user