Skip to content
Browse files

Always construct route objects with Constraint objects

  • Loading branch information...
1 parent 98c7fe8 commit 229c9ed89658cabd74764b7f5a2509bee33d364c @tenderlove tenderlove committed
View
6 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
View
8 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
View
2 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
View
3 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

0 comments on commit 229c9ed

Please sign in to comment.
Something went wrong with that request. Please try again.