Skip to content

Commit

Permalink
fix: correctly escape expanded URL links
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 13, 2018
1 parent 415d9d5 commit d6dbce8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pact_broker/client/hal/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def wrap_response(http_response)
def expand_url(params, url)
new_url = url
params.each do | key, value |
new_url = new_url.gsub('{' + key.to_s + '}', value)
new_url = new_url.gsub('{' + key.to_s + '}', URI.escape(value))
end
new_url
end
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/pact_broker/client/hal/link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ module Hal
it "returns a duplicate Link with the expanded href" do
expect(subject.expand(bar: 'wiffle').href).to eq "http://foo/wiffle"
end

it "returns a duplicate Link with the expanded href with URL escaping" do
expect(subject.expand(bar: 'wiffle meep').href).to eq "http://foo/wiffle%20meep"
end
end
end
end
Expand Down

0 comments on commit d6dbce8

Please sign in to comment.