mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Merge pull request #947 from coderaiser/fix-urlJoin
fix(common) urlJoin replace: ":/" -> "http?s:/"
This commit is contained in:
commit
a379d160f3
@ -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 '?'
|
||||
|
||||
@ -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 = {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user