From d145152655a69479348b0ebc726d4dc19720a12b Mon Sep 17 00:00:00 2001 From: Damon McMinn Date: Wed, 1 Apr 2015 13:14:11 +0100 Subject: [PATCH 1/2] Add test for https://github.com/nodejitsu/node-http-proxy/issues/747 --- test/lib-http-proxy-common-test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/lib-http-proxy-common-test.js b/test/lib-http-proxy-common-test.js index 007ba39a4..3c6ebd1db 100644 --- a/test/lib-http-proxy-common-test.js +++ b/test/lib-http-proxy-common-test.js @@ -299,6 +299,17 @@ describe('lib/http-proxy/common.js', function () { expect(outgoing.ciphers).eql('my-ciphers'); expect(outgoing.secureProtocol).eql('my-secure-protocol'); }); + + // url.parse('').path => null + it('should not pass null as last arg to #urlJoin', function(){ + var outgoing = {}; + common.setupOutgoing(outgoing, {target: + { path: '' } + }, { url : '' }); + + expect(outgoing.path).to.be('/'); + }); + }); describe('#setupSocket', function () { From ab37a224aab6335308d9f0b2c246096259461f89 Mon Sep 17 00:00:00 2001 From: Damon McMinn Date: Wed, 1 Apr 2015 13:19:03 +0100 Subject: [PATCH 2/2] Fix https://github.com/nodejitsu/node-http-proxy/issues/747 --- lib/http-proxy/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 59ece4dfb..225324ebf 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -80,7 +80,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) { // Remark: Can we somehow not use url.parse as a perf optimization? // var outgoingPath = !options.toProxy - ? url.parse(req.url).path + ? (url.parse(req.url).path || '/') : req.url; outgoing.path = common.urlJoin(targetPath, outgoingPath);