Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[padrino-core] Fixed a problem with Sinatra::Request#accept and provi…

…des condition.
  • Loading branch information...
commit 2e1b97a5c36197c45aea5ad7b56154effd1c720f 1 parent 5e09afd
Davide D'Agostino DAddYE authored
4 padrino-core/lib/padrino-core/application/rendering.rb
View
@@ -16,11 +16,11 @@ class TemplateNotFound < RuntimeError #:nodoc:
IGNORE_FILE_PATTERN = [
/~$/ # This is for Gedit
]
-
+
##
# Default rendering options used in the #render-method
#
- DEFAULT_RENDERING_OPTIONS = {:strict_format => false, :raise_exceptions => true}
+ DEFAULT_RENDERING_OPTIONS = { :strict_format => false, :raise_exceptions => true }
def self.registered(app)
app.send(:include, Padrino::Rendering)
6 padrino-core/lib/padrino-core/application/routing.rb
View
@@ -394,14 +394,12 @@ def provides(*types)
mime_types = types.map{ |t| mime_type(t) }
condition {
- matching_types = (request.accept & mime_types)
+ matching_types = (request.accept.map { |a| a.split(";")[0].strip } & mime_types)
request.path_info =~ /\.([^\.\/]+)$/
url_format = $1.to_sym if $1
if !url_format && matching_types.first
- type = (
- Rack::Mime::MIME_TYPES.find { |k, v| v == matching_types.first }[0].sub(/\./,'').to_sym
- )
+ type = Rack::Mime::MIME_TYPES.find { |k, v| v == matching_types.first }[0].sub(/\./,'').to_sym
accept_format = CONTENT_TYPE_ALIASES[type] || type
end
2  padrino-core/test/test_rendering.rb
View
@@ -240,7 +240,7 @@ def teardown
mock_app do
get(:index, :map => "/", :provides => [:html, :rss]){ render 'foo' }
end
- get "/"
+ get "/", {}, { 'HTTP_ACCEPT' => 'text/html;q=0.9' }
assert_equal "Im Html", body
get ".rss"
assert_equal "<rss/>\n", body
Please sign in to comment.
Something went wrong with that request. Please try again.