Fixes accept? to match wildcards in HTTP_ACCEPT.
This commit is contained in:
parent
96c755ed27
commit
ce6ef9f869
|
@ -28,7 +28,7 @@ module Sinatra
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept?(type)
|
def accept?(type)
|
||||||
preferred_type.include?(type)
|
preferred_type(type).include?(type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def preferred_type(*types)
|
def preferred_type(*types)
|
||||||
|
|
|
@ -63,6 +63,11 @@ class RequestTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "accepts types when wildcards are requested" do
|
||||||
|
request = Sinatra::Request.new('HTTP_ACCEPT' => 'image/*')
|
||||||
|
assert request.accept?('image/jpeg')
|
||||||
|
end
|
||||||
|
|
||||||
it "properly decodes MIME type parameters" do
|
it "properly decodes MIME type parameters" do
|
||||||
request = Sinatra::Request.new(
|
request = Sinatra::Request.new(
|
||||||
'HTTP_ACCEPT' => 'image/jpeg;unquoted=0.25;quoted="0.25";chartest="\";,\x"'
|
'HTTP_ACCEPT' => 'image/jpeg;unquoted=0.25;quoted="0.25";chartest="\";,\x"'
|
||||||
|
|
Loading…
Reference in New Issue