Skip to content

Commit

Permalink
Merge branch 'pr-1095' into presubmit-master-pr-1095
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Jun 16, 2014
2 parents e63acb6 + 911c2f1 commit ecb6390
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/middleware/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var parseProxyConfig = function(proxies) {
if (endsWithSlash(proxyPath) && !endsWithSlash(proxyUrl)) {
log.warn('proxy "%s" normalized to "%s"', proxyUrl, proxyUrl + '/');
proxyUrl += '/';
pathname += '/';
}

if (!endsWithSlash(proxyPath) && endsWithSlash(proxyUrl)) {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/middleware/proxy.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,20 @@ describe 'middleware.proxy', ->
baseProxyUrl: '/proxy/test', https:false}
}

it 'should normalize proxy url with only basepaths', ->
proxy = {'/base/': '/proxy/test'}
parsedProxyConfig = m.parseProxyConfig proxy
expect(parsedProxyConfig).to.deep.equal {
'/base/': {host: c.DEFAULT_HOSTNAME, port: c.DEFAULT_PORT,
baseProxyUrl: '/proxy/test/', https:false}
}

it 'should normalize proxy url', ->
proxy = {'/base/': 'http://localhost:8000/proxy/test'}
parsedProxyConfig = m.parseProxyConfig proxy
expect(parsedProxyConfig).to.deep.equal {
'/base/': {host: 'localhost', port: '8000', baseProxyUrl: '/proxy/test/', https:false}
}

it 'should handle empty proxy config', ->
expect(m.parseProxyConfig {}).to.deep.equal({})

0 comments on commit ecb6390

Please sign in to comment.