1
0
Fork 0
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:
Ross Boucher 2012-02-10 13:06:51 -08:00
parent 94707f5f42
commit 311aa42646
2 changed files with 12 additions and 1 deletions

View file

@ -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)

View file

@ -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)/'