diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb index 2135b280dae589f6317c6fae3683ac92bd872210..4be49516bf4f3f0ce5fb4a844a21c8c2e6752b51 100644 --- a/actionpack/lib/action_dispatch/routing/inspector.rb +++ b/actionpack/lib/action_dispatch/routing/inspector.rb @@ -14,10 +14,10 @@ def constraints def rack_app(app = self.app) @rack_app ||= begin + app = app.app class_name = app.class.name.to_s - if class_name == "ActionDispatch::Routing::Mapper::Constraints" - app.app - elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/ + + if ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/ app end end diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index b33c5e0dfd855a7784a0225435957022f941d597..c5e093dae5dcd694c13c7dab5a2d21c37b4da027 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -216,10 +216,12 @@ def normalize_conditions! end def app + endpoint = to.respond_to?(:call) ? to : dispatcher + if blocks.any? Constraints.new(endpoint, blocks, @set.request_class) else - endpoint + Constraints.new(endpoint, blocks, @set.request_class) end end @@ -306,10 +308,6 @@ def strexp Journey::Router::Strexp.compile(path, requirements, SEPARATORS) end - def endpoint - to.respond_to?(:call) ? to : dispatcher - end - def dispatcher Routing::RouteSet::Dispatcher.new(defaults) end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 924455bce22eeb2ed9c842b4bc9884dc4b0999f2..f36453020f63d47f72af6d3644678d3b36d999c7 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -704,7 +704,7 @@ def recognize_path(path, environment = {}) old_params = req.path_parameters req.path_parameters = old_params.merge params dispatcher = route.app - if dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env) + if dispatcher.matches?(env) dispatcher = dispatcher.app end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a427113763d92742e6aefe491667f89d60a6243d..51b5e9cf0757057a6485f04e9c05b162896147d5 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -3389,6 +3389,9 @@ def ip def x_header @env["HTTP_X_HEADER"] || "" end + + def reset_parameters + end end class XHeader