Skip to content
  • Andrew White's avatar
    ea11acd1
    Use more specific check for :format in route path · ea11acd1
    Andrew White authored
    The current check for whether to add an optional format to the path
    is very lax and will match things like `:format_id` where there are
    nested resources, e.g:
    
        resources :formats do
          resources :items
        end
    
    Fix this by using a more restrictive regex pattern that looks for
    the patterns `(.:format)`, `.:format` or `/` at the end of the path.
    Note that we need to allow for multiple closing parenthesis since
    the route may be of this form:
    
        get "/books(/:action(.:format))", controller: "books"
    
    This probably isn't what's intended since it means that the default
    index action route doesn't support a format but we have a test for
    it so we need to allow it.
    
    Fixes #28517.
    ea11acd1
    Use more specific check for :format in route path
    Andrew White authored
    The current check for whether to add an optional format to the path
    is very lax and will match things like `:format_id` where there are
    nested resources, e.g:
    
        resources :formats do
          resources :items
        end
    
    Fix this by using a more restrictive regex pattern that looks for
    the patterns `(.:format)`, `.:format` or `/` at the end of the path.
    Note that we need to allow for multiple closing parenthesis since
    the route may be of this form:
    
        get "/books(/:action(.:format))", controller: "books"
    
    This probably isn't what's intended since it means that the default
    index action route doesn't support a format but we have a test for
    it so we need to allow it.
    
    Fixes #28517.
Loading