Skip to content

Commit

Permalink
do not concatinate params. fixes sinatra#452, fixes sinatra#453.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Mar 7, 2012
1 parent 318b1a5 commit e328934
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def process_route(pattern, keys, conditions, block = nil, values = [])

if values.any?
original, @params = params, params.merge('splat' => [], 'captures' => values)
keys.zip(values) { |k,v| (@params[k] ||= '') << v if v }
keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
end

catch(:pass) do
Expand Down
6 changes: 6 additions & 0 deletions test/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ class RoutingTest < Test::Unit::TestCase
assert_equal "format=", body
end

it 'does not concatinate params with the same name' do
mock_app { get('/:foo') { params[:foo] } }
get '/a?foo=b'
assert_body 'a'
end

it "supports single splat params like /*" do
mock_app {
get '/*' do
Expand Down

0 comments on commit e328934

Please sign in to comment.