Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/parser/functions/uriescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ module Puppet::Parser::Functions

result = if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
value.map { |i| i.is_a?(String) ? URI.escape(i) : i }
value.map { |i| i.is_a?(String) ? URI::DEFAULT_PARSER.escape(i) : i }
else
URI.escape(value)
URI::DEFAULT_PARSER.escape(value)
end

return result
Expand Down
8 changes: 4 additions & 4 deletions spec/functions/uriescape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
end

describe 'handling normal strings' do
it 'calls ruby\'s URI.escape function' do
expect(URI).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once
it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do
expect(URI::DEFAULT_PARSER).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once
is_expected.to run.with_params('uri_string').and_return('escaped_uri_string')
end
end

describe 'handling classes derived from String' do
it 'calls ruby\'s URI.escape function' do
it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do
uri_string = AlsoString.new('uri_string')
expect(URI).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once
expect(URI::DEFAULT_PARSER).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once
is_expected.to run.with_params(uri_string).and_return('escaped_uri_string')
end
end
Expand Down