diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index d469694ec..8a9184bcd 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -35,7 +35,7 @@ def versions_url base_url, pacticipant end def version_url base_url, version - "#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}" + "#{pacticipant_url(base_url, version.pacticipant)}/versions/#{url_encode(version.number)}" end def version_url_from_params params, base_url = '' @@ -157,7 +157,7 @@ def verification_url_from_params params, base_url = '' end def latest_verifications_for_consumer_version_url version, base_url - "#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{version.number}/latest" + "#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{url_encode(version.number)}/latest" end def latest_verification_for_pact_url pact, base_url, permalink = true @@ -198,7 +198,7 @@ def templated_label_url_for_pacticipant pacticipant_name, base_url = "" end def label_url label, base_url - "#{labels_url(label.pacticipant, base_url)}/#{label.name}" + "#{labels_url(label.pacticipant, base_url)}/#{url_encoded(label.name)}" end def labels_url pacticipant, base_url @@ -281,7 +281,7 @@ def matrix_url_from_params params, base_url = '' end def group_url(pacticipant_name, base_url = '') - "#{base_url}/groups/#{pacticipant_name}" + "#{base_url}/groups/#{url_encoded(pacticipant_name)}" end def hal_browser_url target_url, 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 048ca1127..45edc52f1 100644 --- a/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +++ b/spec/lib/pact_broker/api/pact_broker_urls_spec.rb @@ -30,7 +30,7 @@ module Api let(:version) do double('version', pacticipant: consumer, - number: "2") + number: "2/4") end matcher :match_route_in_api do |api| @@ -136,7 +136,7 @@ module Api describe "matrix_for_pacticipant_version_url" do subject { PactBrokerUrls.matrix_for_pacticipant_version_url(version, base_url) } - it { is_expected.to eq "http://example.org/matrix?q[][pacticipant]=Foo%2FFoo&q[][version]=2&latestby=cvpv" } + it { is_expected.to eq "http://example.org/matrix?q[][pacticipant]=Foo%2FFoo&q[][version]=2%2F4&latestby=cvpv" } end describe "matrix_badge_url" do