Ticket #437: fix_format_extension.diff

File fix_format_extension.diff, 1.2 kB (added by chr..@oxdi.eu, 10 months ago)

fix for format_extension

  • lib/merb/mixins/general_controller.rb

    old new  
    161161    end 
    162162     
    163163    # +format_extension+ dictates when named route URLs generated by the url 
    164     # method will have a file extension. It will return either false or the format  
     164    # method will have a file extension. It will return either nil or the format  
    165165    # extension to append. 
    166166    # 
    167167    # ==== Configuration Options 
     
    192192    #   # => /products/3 
    193193    # 
    194194    def format_extension(new_params={}) 
    195       use_format = Merb::Config[:use_format_in_urls] 
    196       if use_format.nil? 
    197         prms = params.merge(new_params) 
    198         use_format = prms[:format] != 'html' && prms[:format] 
     195      format = params.merge(new_params)[:format] || 'html' 
     196      if format != 'html' || always_use_format_extension? 
     197        format || 'html' 
    199198      end 
    200       use_format 
    201199    end 
    202200     
     201    def always_use_format_extension? 
     202      Merb::Config[:use_format_in_urls] 
     203    end 
     204     
    203205         
    204206    # Creates an MD5 hashed token based on the current time. 
    205207    #