Skip to content

Commit

Permalink
fix: add missing URL encoding in various URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jul 12, 2020
1 parent f5363f4 commit 276094b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = ''
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact_broker/api/pact_broker_urls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 276094b

Please sign in to comment.