lib/merb/mixins/general_controller.rb in merb-0.5.1 vs lib/merb/mixins/general_controller.rb in merb-0.5.2
- old
+ new
@@ -159,11 +159,11 @@
"#{prefix}=#{escape(value)}"
end
end
# +format_extension+ dictates when named route URLs generated by the url
- # method will have a file extension. It will return either false or the format
+ # method will have a file extension. It will return either nil or the format
# extension to append.
#
# ==== Configuration Options
#
# By default, non-HTML URLs will be given an extension. It is posible
@@ -190,15 +190,17 @@
#
# url(:edit_product, :id => 3, :format => 'html')
# # => /products/3
#
def format_extension(new_params={})
- use_format = Merb::Config[:use_format_in_urls]
- if use_format.nil?
- prms = params.merge(new_params)
- use_format = prms[:format] != 'html' && prms[:format]
+ format = params.merge(new_params)[:format] || 'html'
+ if format != 'html' || always_use_format_extension?
+ format || 'html'
end
- use_format
+ end
+
+ def always_use_format_extension?
+ Merb::Config[:use_format_in_urls]
end
# Creates an MD5 hashed token based on the current time.
#