Skip to content

Commit

Permalink
[Fixes #35655999] Gem does not strip "/" from target url
Browse files Browse the repository at this point in the history
Change-Id: I73c62f5b0f35ad577f47269820416543027d1b45
  • Loading branch information
dsyer committed Sep 7, 2012
1 parent ae74e32 commit 0ed4e81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gem/lib/cli/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def config_pp(tgt = nil, ctx = nil)
end

def normalize_url(url, scheme = nil)
url.strip!
while url.end_with? "/"
url.chomp! "/"
end
raise ArgumentError, "invalid whitespace in target url" if url =~ /\s/
unless url =~ /^https?:\/\//
return unless scheme
Expand Down
6 changes: 6 additions & 0 deletions gem/spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ module CF::UAA
Config.yaml.should match "https://example.com"
end

it "should strip trailing / from target" do
Cli.run("target example.com/uaa/ --force")
Config.yaml.should match "https://example.com/uaa"
Config.yaml.should_not match "https://example.com/uaa/"
end

it "should set multiple targets and see them fully qualified in config and targets output" do
Cli.run("target example.com --force")
Cli.run("target example2.com --force")
Expand Down

0 comments on commit 0ed4e81

Please sign in to comment.