Tim Alby 8 роки тому
батько
коміт
bbed5fca9a

+ 1 - 19
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)

+ 5 - 9
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 = path: 'baz', baseUrl: 'foo.bar/'
-			@proxyManager.makeTargetUrl(target).should.equal 'foo.bar/baz'
+			target = baseUrl: 'foo.bar'
+			@proxyManager.makeTargetUrl(target).should.equal 'foo.bar'
 
-		it 'makes with settingsUrl', ->
-			@settings.apis = v1: url: 'foo.bar/'
-			target = path: 'baz', baseUrl: { setting: 'apis.v1.url' }
+		it 'makes with baseUrl and path', ->
+			target = path: 'baz', baseUrl: 'foo.bar/'
 			@proxyManager.makeTargetUrl(target).should.equal 'foo.bar/baz'
-
-			target = path: 'baz', baseUrl: { setting: 'incorrect.setting' }
-			expect(@proxyManager.makeTargetUrl(target)).to.equal null