From ac9a3a9d641a44f43796b342f76c5b342ae82de6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 May 2014 16:00:40 -0700 Subject: return early if we have a valid controller name --- actionpack/lib/action_dispatch/routing/mapper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 528bcd4189..b8aadff5e6 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -294,16 +294,16 @@ module ActionDispatch end return unless controller + return if controller =~ /\A[a-z_0-9][a-z_0-9\/]*\z/ if controller =~ %r{\A/} - raise ArgumentError, "controller name should not start with a slash" - end - - if controller !~ /\A[a-z_0-9\/]*\z/ + message = "controller name should not start with a slash" + else message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems." message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use" - raise ArgumentError, message end + + raise ArgumentError, message end def blocks -- cgit v1.2.3