diff --git a/lib-src/cfenv.coffee b/lib-src/cfenv.coffee index d9e964e..c2f7d09 100644 --- a/lib-src/cfenv.coffee +++ b/lib-src/cfenv.coffee @@ -88,6 +88,8 @@ class AppEnv delete replacements.url + return url if _.isEmpty replacements + purl = URL.parse url for key, value of replacements diff --git a/lib/cfenv.js b/lib/cfenv.js index df54034..b7b3b57 100644 --- a/lib/cfenv.js +++ b/lib/cfenv.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.12.2 (function() { var AppEnv, URL, _, cfenv, fs, getApp, getBind, getName, getPort, getServices, getURLs, pkg, ports, throwError, yaml; @@ -25,7 +25,6 @@ AppEnv = (function() { function AppEnv(options) { - var error; if (options == null) { options = {}; } @@ -115,6 +114,9 @@ return null; } delete replacements.url; + if (_.isEmpty(replacements)) { + return url; + } purl = URL.parse(url); for (key in replacements) { value = replacements[key]; @@ -142,7 +144,7 @@ })(); getApp = function(appEnv, options) { - var e, envValue, error, locValue, ref, string; + var e, envValue, locValue, ref, string; string = process.env.VCAP_APPLICATION; envValue = {}; if (string != null) { @@ -164,7 +166,7 @@ }; getServices = function(appEnv, options) { - var e, envValue, error, locValue, ref, string; + var e, envValue, locValue, ref, string; string = process.env.VCAP_SERVICES; envValue = {}; if (string != null) { @@ -202,7 +204,7 @@ }; getName = function(appEnv, options) { - var error, pObject, pString, ref, val, yObject, yString; + var pObject, pString, ref, val, yObject, yString; if (options.name != null) { return options.name; } diff --git a/lib/server.js b/lib/server.js index 17b0812..cdd23d0 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.12.2 (function() { var JL, JS, cfenv, generateDump, http; diff --git a/package.json b/package.json index e75db88..b9b8411 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "url": "https://github.com/cloudfoundry-community/node-cfenv.git" }, "dependencies": { - "js-yaml": "3.4.x", + "js-yaml": "3.7.x", "ports": "1.1.x", "underscore": "1.8.x" }, "devDependencies": { - "coffee-script": "1.10.x", - "mocha": "2.3.x", + "coffee-script": "1.12.x", + "mocha": "3.2.x", "expect.js": "0.3.x" } } diff --git a/tests/test-core.coffee b/tests/test-core.coffee index 43ea2fb..6c69b53 100644 --- a/tests/test-core.coffee +++ b/tests/test-core.coffee @@ -190,6 +190,16 @@ describe "appEnv", -> expect(url).to.be "org-protocol://org-host:666/org-path" + #------------------------------------------- + testURL = "mongodb://user:pass@example.com:18394,example.com:18394/admin" + vcap = getVCAPServicesWithCreds "service-a", + uri: testURL + + appEnv = cfenv.getAppEnv {vcap} + url = appEnv.getServiceURL "service-a" + + expect(url).to.be testURL + #----------------------------------------------------------------------------- it "local - getServiceCreds()", -> @@ -294,7 +304,7 @@ describe "appEnv", -> expect(appEnv.url).to.be "https://sample-uri.example.com" url = appEnv.getServiceURL "service-a" - expect(url).to.be "http://example.com/" + expect(url).to.be "http://example.com" #----------------------------------------------------------------------------- it "name - from option", ->