From 80df832dbb0992e6eefd7530477860aabf04e214 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Mon, 7 Dec 2020 14:17:48 +1100 Subject: [PATCH] fix: url encode tag name in tag URL --- lib/pact_broker/api/pact_broker_urls.rb | 2 +- spec/lib/pact_broker/api/pact_broker_urls_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index 74278baeb..0cabda3cd 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -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 = "" diff --git a/spec/lib/pact_broker/api/pact_broker_urls_spec.rb b/spec/lib/pact_broker/api/pact_broker_urls_spec.rb index 073228703..541b18fc5 100644 --- a/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +++ b/spec/lib/pact_broker/api/pact_broker_urls_spec.rb @@ -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| @@ -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