From 76cb7eeba9c14fec8069eca097bea3cfd21891e2 Mon Sep 17 00:00:00 2001 From: Andrew Crites Date: Sun, 28 Feb 2016 22:42:02 -0500 Subject: [PATCH] Fixing 245: Parse basic auth from URL and submit with http adapter --- lib/adapters/http.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 395dd1c..de68369 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -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