aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-09-02 06:35:44 -0400
committereileencodes <eileencodes@gmail.com>2015-09-02 09:18:46 -0400
commitec14aad419381b502f510a9b3360f0e211e41066 (patch)
tree2e2a88802d6890185a872ff7fa35ec82778b4006 /actionpack/lib/action_dispatch/journey
parent1829943943f9f52e02ca15430490a53d1a1ec0b5 (diff)
downloadrails-ec14aad419381b502f510a9b3360f0e211e41066.tar.gz
rails-ec14aad419381b502f510a9b3360f0e211e41066.tar.bz2
rails-ec14aad419381b502f510a9b3360f0e211e41066.zip
Fix route creation when format is a blank string
Commit bff61ba, while reducing allocations, caused a regression when an empty format is passed to a route. This can happen in cases where you're using an anchor tag, for example: `https://example.com/parent/575256966.#child_1032289285`. Because of this change `format` was getting sent in `parameterized_parts` when previously it was not included. This resulted in blank `format`'s being returned as `.` when if there was an extension included it would be `.extension`. Since there was no extension this caused incorrect URL's. The test shows this would result in `/posts/show/1.` instead of `/posts/show/1` which causes bad urls since the format is not present.
Diffstat (limited to 'actionpack/lib/action_dispatch/journey')
-rw-r--r--actionpack/lib/action_dispatch/journey/formatter.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb
index c19ff0f4db..0323360faa 100644
--- a/actionpack/lib/action_dispatch/journey/formatter.rb
+++ b/actionpack/lib/action_dispatch/journey/formatter.rb
@@ -33,7 +33,7 @@ module ActionDispatch
defaults = route.defaults
required_parts = route.required_parts
parameterized_parts.keep_if do |key, value|
- defaults[key].nil? || value.to_s != defaults[key].to_s || required_parts.include?(key)
+ (defaults[key].nil? && value.present?) || value.to_s != defaults[key].to_s || required_parts.include?(key)
end
return [route.format(parameterized_parts), params]