Merge pull request #947 from coderaiser/fix-urlJoin

fix(common) urlJoin replace: ":/" -> "http?s:/"
This commit is contained in:
Jarrett Cruger 2016-02-01 20:59:18 -08:00
commit a379d160f3
2 changed files with 26 additions and 1 deletions

View File

@ -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 '?'

View File

@ -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 = {};