diff --git a/services/web/app/coffee/infrastructure/ProxyManager.coffee b/services/web/app/coffee/infrastructure/ProxyManager.coffee index 45ca6b7a48..d93c696ab1 100644 --- a/services/web/app/coffee/infrastructure/ProxyManager.coffee +++ b/services/web/app/coffee/infrastructure/ProxyManager.coffee @@ -18,26 +18,8 @@ module.exports = # - an Object with: # - a path attribute (String) # - a baseURL attribute (String) - # - a baseURL attribute (Object) with: - # - a setting attribute pointing to a value in the settings makeTargetUrl: (target) -> return target if typeof target is 'string' return target.path unless target.baseUrl? + "#{target.baseUrl}#{target.path or ''}" - if typeof target.baseUrl is 'string' - baseUrl = target.baseUrl - else if target.baseUrl.setting? - baseUrl = digSettingValue target.baseUrl.setting - - return null unless baseUrl? - "#{baseUrl}#{target.path}" - -# given a setting path (e.g. 'apis.v1.url') recursively find the corresponding -# settings value -digSettingValue = (attributesPath, dig = null) -> - dig ||= settings - [nextAttribute, leftAttributes...] = attributesPath.split('.') - dig = dig[nextAttribute] - return null unless dig? - return dig if leftAttributes.length == 0 - digSettingValue(leftAttributes.join('.'), dig) diff --git a/services/web/test/unit/coffee/infrastructure/ProxyManagerTests.coffee b/services/web/test/unit/coffee/infrastructure/ProxyManagerTests.coffee index 3c3c4c7ccd..5782a4e2fc 100644 --- a/services/web/test/unit/coffee/infrastructure/ProxyManagerTests.coffee +++ b/services/web/test/unit/coffee/infrastructure/ProxyManagerTests.coffee @@ -47,18 +47,14 @@ describe "ProxyManager", -> target = 'http://whatever' @proxyManager.makeTargetUrl(target).should.equal target - it 'makes from object', -> + it 'makes with path', -> target = path: 'baz' @proxyManager.makeTargetUrl(target).should.equal 'baz' it 'makes with baseUrl', -> + target = baseUrl: 'foo.bar' + @proxyManager.makeTargetUrl(target).should.equal 'foo.bar' + + it 'makes with baseUrl and path', -> target = path: 'baz', baseUrl: 'foo.bar/' @proxyManager.makeTargetUrl(target).should.equal 'foo.bar/baz' - - it 'makes with settingsUrl', -> - @settings.apis = v1: url: 'foo.bar/' - target = path: 'baz', baseUrl: { setting: 'apis.v1.url' } - @proxyManager.makeTargetUrl(target).should.equal 'foo.bar/baz' - - target = path: 'baz', baseUrl: { setting: 'incorrect.setting' } - expect(@proxyManager.makeTargetUrl(target)).to.equal null