Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow ampersands in URL parameters, fixes GH #37.

  • Loading branch information...
commit 2233cdbf683c3a54351a24dce3be2e5875cb2a76 1 parent 12c1157
@rkh authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  lib/sinatra/base.rb
  2. +12 −0 test/routing_test.rb
View
2  lib/sinatra/base.rb
@@ -932,7 +932,7 @@ def compile(path)
Regexp.escape(match)
else
keys << $2[1..-1]
- "([^/?&#]+)"
+ "([^/?#]+)"
end
end
[/^#{pattern}$/, keys]
View
12 test/routing_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.