Skip to content

Commit aa8f3e9

Browse files
committed
Merge pull request #798 from damonmcminn/master
Fix #747
2 parents 87a92a7 + ab37a22 commit aa8f3e9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/http-proxy/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
8080
// Remark: Can we somehow not use url.parse as a perf optimization?
8181
//
8282
var outgoingPath = !options.toProxy
83-
? url.parse(req.url).path
83+
? (url.parse(req.url).path || '/')
8484
: req.url;
8585

8686
outgoing.path = common.urlJoin(targetPath, outgoingPath);

test/lib-http-proxy-common-test.js

+11
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,17 @@ describe('lib/http-proxy/common.js', function () {
299299
expect(outgoing.ciphers).eql('my-ciphers');
300300
expect(outgoing.secureProtocol).eql('my-secure-protocol');
301301
});
302+
303+
// url.parse('').path => null
304+
it('should not pass null as last arg to #urlJoin', function(){
305+
var outgoing = {};
306+
common.setupOutgoing(outgoing, {target:
307+
{ path: '' }
308+
}, { url : '' });
309+
310+
expect(outgoing.path).to.be('/');
311+
});
312+
302313
});
303314

304315
describe('#setupSocket', function () {

0 commit comments

Comments
 (0)