Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't parse url for getServiceURL unless required #22

Merged
merged 1 commit into from
Jan 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib-src/cfenv.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class AppEnv

delete replacements.url

return url if _.isEmpty replacements

purl = URL.parse url

for key, value of replacements
Expand Down
12 changes: 7 additions & 5 deletions lib/cfenv.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
12 changes: 11 additions & 1 deletion tests/test-core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()", ->

Expand Down Expand Up @@ -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", ->
Expand Down