Allow ampersands in URL parameters, fixes GH #37.

This commit is contained in:
Konstantin Haase 2010-09-03 08:49:30 +02:00
parent 12c11578f5
commit 2233cdbf68
2 changed files with 13 additions and 1 deletions

View File

@ -932,7 +932,7 @@ module Sinatra
Regexp.escape(match)
else
keys << $2[1..-1]
"([^/?&#]+)"
"([^/?#]+)"
end
end
[/^#{pattern}$/, keys]

View File

@ -356,6 +356,18 @@ class RoutingTest < Test::Unit::TestCase
assert_equal 'looks good', body
end
it "matches paths that include ampersands" do
mock_app {
get '/:name' do
'looks good'
end
}
get '/foo&bar'
assert ok?
assert_equal 'looks good', body
end
it "URL decodes named parameters and splats" do
mock_app {
get '/:foo/*' do