Skip to content

Commit

Permalink
Avoid infinite recursion when there is a redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
stormsilver committed Feb 27, 2015
1 parent 79499b1 commit 0671d85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/apipie/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def rails_routes(route_set = nil)

# the app might be nested when using contraints, namespaces etc.
# this method does in depth search for the route controller
def route_app_controller(app, route)
def route_app_controller(app, route, visited_apps = [])
visited_apps << app
if app.respond_to?(:controller)
return app.controller(route.defaults)
elsif app.respond_to?(:app)
return route_app_controller(app.app, route)
elsif app.respond_to?(:app) && !visited_apps.include?(app.app)
return route_app_controller(app.app, route, visited_apps)
end
rescue ActionController::RoutingError
# some errors in the routes will not stop us here: just ignoring
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
apipie
end
root :to => 'apipie/apipies#index'
match '(/)*path' => redirect('http://www.example.com'), :via => :all
end

0 comments on commit 0671d85

Please sign in to comment.