Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/http-proxy/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ common.urlJoin = function() {
// joining e.g. ['', 'am']
//
retSegs = [
args.filter(Boolean).join('/').replace(/\/+/g, '/').replace(/:\//g, '://')
args.filter(Boolean).join('/')
.replace(/\/+/g, '/')
.replace('http:/', 'http://')
.replace('https:/', 'https://')
];

// Only join the query string if it exists so we don't have trailing a '?'
Expand Down
22 changes: 22 additions & 0 deletions test/lib-http-proxy-common-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,28 @@ describe('lib/http-proxy/common.js', function () {
expect(outgoing.path).to.eql('/' + google);
});

it('should not replace :\ to :\\ when no https word before', function () {
var outgoing = {};
var google = 'https://google.com:/join/join.js'
common.setupOutgoing(outgoing, {
target: url.parse('http://sometarget.com:80'),
toProxy: true,
}, { url: google });

expect(outgoing.path).to.eql('/' + google);
});

it('should not replace :\ to :\\ when no http word before', function () {
var outgoing = {};
var google = 'http://google.com:/join/join.js'
common.setupOutgoing(outgoing, {
target: url.parse('http://sometarget.com:80'),
toProxy: true,
}, { url: google });

expect(outgoing.path).to.eql('/' + google);
});

describe('when using ignorePath', function () {
it('should ignore the path of the `req.url` passed in but use the target path', function () {
var outgoing = {};
Expand Down