Skip to content

Commit

Permalink
fix: url encode tag name in tag URL
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Dec 7, 2020
1 parent a968e0e commit 80df832
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def verification_publication_url pact, base_url, metadata = ""
end

def tag_url base_url, tag
"#{tags_url(base_url, tag.version)}/#{tag.name}"
"#{tags_url(base_url, tag.version)}/#{url_encode(tag.name)}"
end

def templated_tag_url_for_pacticipant pacticipant_name, base_url = ""
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/pact_broker/api/pact_broker_urls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Api
pacticipant: consumer,
number: "2/4")
end
let(:tag) { double('tag', name: "feat/foo", version: version) }

matcher :match_route_in_api do |api|
match do |url|
Expand Down Expand Up @@ -168,6 +169,13 @@ module Api

it { is_expected.to eq "http://example.org/matrix/provider/Bar%2FBar/latest/meep/consumer/Foo%2FFoo/latest/bar/badge.svg" }
end

describe "tag_url" do
subject { PactBrokerUrls.tag_url(base_url, tag) }

it { is_expected.to match_route_in_api(PactBroker::API) }
it { is_expected.to eq "http://example.org/pacticipants/Foo%2FFoo/versions/2%2F4/tags/feat%2Ffoo" }
end
end
end
end

0 comments on commit 80df832

Please sign in to comment.