From 996e9f568cba400cf82ececbc69ea797b863644b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 May 2014 15:56:12 -0700 Subject: trade 2 is_a? checks for a nil check --- actionpack/lib/action_dispatch/routing/mapper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 e8dd54b3f0..528bcd4189 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -293,11 +293,13 @@ module ActionDispatch raise ArgumentError, message end - if controller.is_a?(String) && controller =~ %r{\A/} + return unless controller + + if controller =~ %r{\A/} raise ArgumentError, "controller name should not start with a slash" end - if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/ + if controller !~ /\A[a-z_0-9\/]*\z/ 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 -- cgit v1.2.3