mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Plus symbols in the URL should be converted to spaces when considered as param values.
Closes #463.
This commit is contained in:
parent
94707f5f42
commit
311aa42646
2 changed files with 12 additions and 1 deletions
|
@ -825,7 +825,7 @@ module Sinatra
|
|||
route = @request.path_info
|
||||
route = '/' if route.empty? and not settings.empty_path_info?
|
||||
return unless match = pattern.match(route)
|
||||
values += match.captures.to_a.map { |v| force_encoding URI.decode(v) if v }
|
||||
values += match.captures.to_a.map { |v| force_encoding URI.decode_www_form_component(v) if v }
|
||||
|
||||
if values.any?
|
||||
original, @params = params, params.merge('splat' => [], 'captures' => values)
|
||||
|
|
|
@ -329,6 +329,17 @@ class RoutingTest < Test::Unit::TestCase
|
|||
assert not_found?
|
||||
end
|
||||
|
||||
it "converts plus sign into space as the value of a named param" do
|
||||
mock_app {
|
||||
get '/:test' do
|
||||
params["test"]
|
||||
end
|
||||
}
|
||||
get '/bob+ross'
|
||||
assert ok?
|
||||
assert_equal 'bob ross', body
|
||||
end
|
||||
|
||||
it "literally matches parens in paths" do
|
||||
route_def '/test(bar)/'
|
||||
|
||||
|
|
Loading…
Reference in a new issue