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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user