2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Polyfilling btoa where appropriate

Includes testing of the polyfills.
This commit is contained in:
Idan Gazit
2015-12-10 17:22:39 +02:00
parent af170334bd
commit 603e7c84a0
3 changed files with 71 additions and 62 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ var buildURL = require('./../helpers/buildURL');
var parseHeaders = require('./../helpers/parseHeaders');
var transformData = require('./../helpers/transformData');
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
var btoa = window.btoa || require('./../helpers/btoa.js')
module.exports = function xhrAdapter(resolve, reject, config) {
// Transform request data
@@ -41,9 +42,9 @@ module.exports = function xhrAdapter(resolve, reject, config) {
// HTTP basic authentication
if (config.auth) {
requestHeaders['Authorization'] = 'Basic: ' + window.btoa(username + ':' + password);
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders['Authorization'] = 'Basic: ' + btoa(username + ':' + password);
}
// Create the request