diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-14 12:08:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-14 12:08:30 -0700 |
commit | 565582c0f5f1fe17357df67978e2f684db305bf9 (patch) | |
tree | 9afc47975404e16f238e3e21ce38be7d58a7d785 /actionpack/lib/action_dispatch | |
parent | b543ee74f4cc44bcef6dac92859c77810e08dbdb (diff) | |
download | rails-565582c0f5f1fe17357df67978e2f684db305bf9.tar.gz rails-565582c0f5f1fe17357df67978e2f684db305bf9.tar.bz2 rails-565582c0f5f1fe17357df67978e2f684db305bf9.zip |
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
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
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) |