2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-21 13:24:11 +03:00

Fixing 245:

Parse basic auth from URL and submit with http adapter
This commit is contained in:
Andrew Crites
2016-02-28 22:42:02 -05:00
parent dbd2c11454
commit 76cb7eeba9
+7 -1
View File
@@ -46,6 +46,12 @@ module.exports = function httpAdapter(resolve, reject, config) {
// Parse url
var parsed = url.parse(config.url);
if (!auth && parsed.auth) {
var urlAuth = parsed.auth.split(":");
var urlUsername = urlAuth[0] || "";
var urlPassword = urlAuth[1] || "";
auth = urlUsername + ':' + urlPassword;
}
var options = {
hostname: parsed.hostname,
port: parsed.port,
@@ -53,7 +59,7 @@ module.exports = function httpAdapter(resolve, reject, config) {
method: config.method,
headers: headers,
agent: config.agent,
auth: auth
auth: auth || parsed.auth,
};
// Create the request