Skip to content

Commit 276094b

Browse files
committed
fix: add missing URL encoding in various URLs
1 parent f5363f4 commit 276094b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/pact_broker/api/pact_broker_urls.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def versions_url base_url, pacticipant
3535
end
3636

3737
def version_url base_url, version
38-
"#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}"
38+
"#{pacticipant_url(base_url, version.pacticipant)}/versions/#{url_encode(version.number)}"
3939
end
4040

4141
def version_url_from_params params, base_url = ''
@@ -157,7 +157,7 @@ def verification_url_from_params params, base_url = ''
157157
end
158158

159159
def latest_verifications_for_consumer_version_url version, base_url
160-
"#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{version.number}/latest"
160+
"#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{url_encode(version.number)}/latest"
161161
end
162162

163163
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 = ""
198198
end
199199

200200
def label_url label, base_url
201-
"#{labels_url(label.pacticipant, base_url)}/#{label.name}"
201+
"#{labels_url(label.pacticipant, base_url)}/#{url_encoded(label.name)}"
202202
end
203203

204204
def labels_url pacticipant, base_url
@@ -281,7 +281,7 @@ def matrix_url_from_params params, base_url = ''
281281
end
282282

283283
def group_url(pacticipant_name, base_url = '')
284-
"#{base_url}/groups/#{pacticipant_name}"
284+
"#{base_url}/groups/#{url_encoded(pacticipant_name)}"
285285
end
286286

287287
def hal_browser_url target_url, base_url = ''

spec/lib/pact_broker/api/pact_broker_urls_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Api
3030
let(:version) do
3131
double('version',
3232
pacticipant: consumer,
33-
number: "2")
33+
number: "2/4")
3434
end
3535

3636
matcher :match_route_in_api do |api|
@@ -136,7 +136,7 @@ module Api
136136
describe "matrix_for_pacticipant_version_url" do
137137
subject { PactBrokerUrls.matrix_for_pacticipant_version_url(version, base_url) }
138138

139-
it { is_expected.to eq "http://example.org/matrix?q[][pacticipant]=Foo%2FFoo&q[][version]=2&latestby=cvpv" }
139+
it { is_expected.to eq "http://example.org/matrix?q[][pacticipant]=Foo%2FFoo&q[][version]=2%2F4&latestby=cvpv" }
140140
end
141141

142142
describe "matrix_badge_url" do

0 commit comments

Comments
 (0)