mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #1390 from iguchi1124/fix-captured-paths
Fix to ignore empty captures from params
This commit is contained in:
commit
05cb1fe2fe
2 changed files with 16 additions and 1 deletions
|
@ -1029,7 +1029,7 @@ module Sinatra
|
||||||
if regexp_exists
|
if regexp_exists
|
||||||
captures = pattern.match(route).captures
|
captures = pattern.match(route).captures
|
||||||
values += captures
|
values += captures
|
||||||
@params[:captures] = captures
|
@params[:captures] = captures unless captures.nil? || captures.empty?
|
||||||
else
|
else
|
||||||
values += params.values.flatten
|
values += params.values.flatten
|
||||||
end
|
end
|
||||||
|
|
|
@ -216,6 +216,21 @@ class RoutingTest < Minitest::Test
|
||||||
assert_equal "This is not a drill either", response.body
|
assert_equal "This is not a drill either", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns empty when unmatched with any regex captures" do
|
||||||
|
mock_app do
|
||||||
|
before do
|
||||||
|
# noop
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/hello' do
|
||||||
|
params.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert get('/hello').ok?
|
||||||
|
assert_body '{}'
|
||||||
|
end
|
||||||
|
|
||||||
it "uses 404 error handler for not matching route" do
|
it "uses 404 error handler for not matching route" do
|
||||||
mock_app {
|
mock_app {
|
||||||
not_found do
|
not_found do
|
||||||
|
|
Loading…
Reference in a new issue