From 565582c0f5f1fe17357df67978e2f684db305bf9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Aug 2015 12:08:30 -0700 Subject: explicitly return nil from `get_to_from_path` if `to` was initialized, this method would return, so we can eliminate the to ||= in the conditional. Finally, let's return a nil in the else block so that it's explicit that this method can return nil --- actionpack/lib/action_dispatch/routing/mapper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 5cf3d2f3e9..4411625e51 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1569,10 +1569,10 @@ to this: path_without_format = path.sub(/\(\.:format\)$/, '') if using_match_shorthand?(path_without_format) - to ||= path_without_format.gsub(%r{^/}, "").sub(%r{/([^/]*)$}, '#\1') - to.tr!("-", "_") + path_without_format.gsub(%r{^/}, "").sub(%r{/([^/]*)$}, '#\1').tr("-", "_") + else + nil end - to end def process_path(options, controller, path, option_path, to, via, formatted, ancho, options_constraintsr) -- cgit v1.2.3