1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

invert check so we fail faster

there's no reason to to_sym the string if it doesn't match the regexp
anyway
This commit is contained in:
Aaron Patterson 2014-07-31 11:25:01 -07:00
parent 3e9158bb95
commit ed9b23d898

View file

@ -1765,7 +1765,7 @@ module ActionDispatch
# and return nil in case it isn't. Otherwise, we pass the invalid name
# forward so the underlying router engine treats it and raises an exception.
if as.nil?
candidate unless @set.named_routes.key?(candidate) || candidate !~ /\A[_a-z]/i
candidate unless candidate !~ /\A[_a-z]/i || @set.named_routes.key?(candidate)
else
candidate
end