Comparing version 2.1.1 to 2.1.2
@@ -171,2 +171,3 @@ ////////////////////////////////////////// | ||
} | ||
} | ||
@@ -246,3 +247,3 @@ | ||
if (uri.indexOf('@') !== -1) { // url contains user:pass@host, so parse it. | ||
if (uri.match(/[^\/]@/)) { // url contains user:pass@host, so parse it. | ||
var parts = (url.parse(uri).auth || '').split(':'); | ||
@@ -713,3 +714,2 @@ options.username = parts[0]; | ||
if (post_data) { | ||
@@ -742,4 +742,4 @@ if (is_stream(post_data)) { | ||
if (verb.match(/get|head/) && args.length == 1) | ||
args.splice(1, 0, null); // assume no data if head/get with one argument (options) | ||
if (verb.match(/get|head/) && args.length == 2) | ||
args.splice(1, 0, null); // assume no data if head/get with two args (url, options) | ||
@@ -746,0 +746,0 @@ return new Promise(function(resolve, reject) { |
{ | ||
"name": "needle", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "The leanest and most handsome HTTP client in the Nodelands.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -149,2 +149,25 @@ var helpers = require('./helpers'), | ||
describe('URL with @ but not username/pass', function() { | ||
it('doesnt send Authorization header', function(done) { | ||
var url = 'localhost:' + port + '/abc/@def/xyz.zip'; | ||
needle.get(url, {}, function(err, resp) { | ||
var sent_headers = resp.body.headers; | ||
Object.keys(sent_headers).should.not.containEql('authorization'); | ||
done(); | ||
}) | ||
}) | ||
it('sends user:pass headers if passed via options', function(done) { | ||
var url = 'localhost:' + port + '/abc/@def/xyz.zip'; | ||
needle.get(url, { username: 'foo' }, function(err, resp) { | ||
var sent_headers = resp.body.headers; | ||
Object.keys(sent_headers).should.containEql('authorization'); | ||
sent_headers['authorization'].should.eql('Basic Zm9v') | ||
done(); | ||
}) | ||
}) | ||
}) | ||
describe('when username/password are included in URL', function() { | ||
@@ -151,0 +174,0 @@ var opts = { parse: true }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192862
42
4539