mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Making btoa polyfill more standard
This commit is contained in:
+3
-2
@@ -8,6 +8,7 @@ function InvalidCharacterError(message) {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
InvalidCharacterError.prototype = new Error;
|
InvalidCharacterError.prototype = new Error;
|
||||||
|
InvalidCharacterError.prototype.code = 5;
|
||||||
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
||||||
|
|
||||||
function btoa (input) {
|
function btoa (input) {
|
||||||
@@ -24,11 +25,11 @@ function btoa (input) {
|
|||||||
) {
|
) {
|
||||||
charCode = str.charCodeAt(idx += 3/4);
|
charCode = str.charCodeAt(idx += 3/4);
|
||||||
if (charCode > 0xFF) {
|
if (charCode > 0xFF) {
|
||||||
throw new InvalidCharacterError('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
|
throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');
|
||||||
}
|
}
|
||||||
block = block << 8 | charCode;
|
block = block << 8 | charCode;
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = btoa
|
module.exports = btoa;
|
||||||
|
|||||||
Reference in New Issue
Block a user