get '/' should match even if PATH_INFO is empty. This fixes compatibility with Rails 3.
Signed-off-by: Simon Rozet <simon@rozet.name>
This commit is contained in:
parent
f513df6bd4
commit
75d74a413a
|
@ -466,7 +466,9 @@ module Sinatra
|
|||
def route!(base=self.class, pass_block=nil)
|
||||
if routes = base.routes[@request.request_method]
|
||||
original_params = @params
|
||||
|
||||
path = unescape(@request.path_info)
|
||||
path = "/" if path.empty?
|
||||
|
||||
routes.each do |pattern, keys, conditions, block|
|
||||
if match = pattern.match(path)
|
||||
|
|
|
@ -84,6 +84,18 @@ class RoutingTest < Test::Unit::TestCase
|
|||
assert_equal "<h1>Not Found</h1>", response.body
|
||||
end
|
||||
|
||||
it 'matches empty PATH_INFO to "/"' do
|
||||
mock_app {
|
||||
get '/' do
|
||||
'worked'
|
||||
end
|
||||
}
|
||||
|
||||
get '/', {}, "PATH_INFO" => ""
|
||||
assert ok?
|
||||
assert_equal 'worked', body
|
||||
end
|
||||
|
||||
it 'takes multiple definitions of a route' do
|
||||
mock_app {
|
||||
user_agent(/Foo/)
|
||||
|
|
Loading…
Reference in New Issue