Permalink
Browse files

Allow ampersands in URL parameters, fixes GH #37.

  • Loading branch information...
1 parent 12c1157 commit 2233cdbf683c3a54351a24dce3be2e5875cb2a76 @rkh committed Sep 3, 2010
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/sinatra/base.rb
  2. +12 −0 test/routing_test.rb
View
@@ -932,7 +932,7 @@ def compile(path)
Regexp.escape(match)
else
keys << $2[1..-1]
- "([^/?&#]+)"
+ "([^/?#]+)"
end
end
[/^#{pattern}$/, keys]
View
@@ -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

0 comments on commit 2233cdb

Please sign in to comment.