Skip to content

Commit

Permalink
fix: trim trailing slash from base url
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed May 3, 2023
1 parent 5a856d3 commit ccd6417
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/pact_broker/client/cli/custom_thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ class AuthError < ::Thor::Error; end
class CustomThor < ::Thor
using PactBroker::Client::HashRefinements

def initialize(args = nil, options = nil, config = nil)
super(args, options, config)
postprocess_options
end

def postprocess_options
new_options = {}
if options.include?("broker_base_url")
new_options["broker_base_url"] = options["broker_base_url"].chomp('/')
end
self.options = options.merge(new_options)
end

no_commands do
def self.exit_on_failure?
true
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/pact_broker/client/cli/custom_thor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ def test_without_parameters
end
end

it "removes trailing slashes from the broker base url" do
expect(Delegate).to receive(:call) do | options |
expect(options.broker_base_url).to eq 'http://bar'
end
TestThor.start(%w{test_using_env_vars --broker-base-url http://bar/})
end

describe ".turn_muliple_tag_options_into_array" do
it "turns '--tag foo --tag bar' into '--tag foo bar'" do
input = %w{--ignore this --tag foo --tag bar --wiffle --that}
Expand Down

0 comments on commit ccd6417

Please sign in to comment.