mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +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
|
// Parse url
|
||||||
var parsed = url.parse(config.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 = {
|
var options = {
|
||||||
hostname: parsed.hostname,
|
hostname: parsed.hostname,
|
||||||
port: parsed.port,
|
port: parsed.port,
|
||||||
@@ -53,7 +59,7 @@ module.exports = function httpAdapter(resolve, reject, config) {
|
|||||||
method: config.method,
|
method: config.method,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
agent: config.agent,
|
agent: config.agent,
|
||||||
auth: auth
|
auth: auth || parsed.auth,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the request
|
// Create the request
|
||||||
|
|||||||
Reference in New Issue
Block a user