From f36dafa492e3de66e624d81d6860f5f0536de6b0 Mon Sep 17 00:00:00 2001 From: Seth Fitzsimmons Date: Mon, 15 Dec 2008 12:00:55 -0600 Subject: Implement Mime::Type.=~ to match all synonyms against arg [#1573 state:resolved] Signed-off-by: Joshua Peek --- actionpack/lib/action_controller/mime_type.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/lib/action_controller/mime_type.rb') diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index 6923a13f3f..43b3da8d35 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -176,6 +176,14 @@ module Mime end end + def =~(mime_type) + return false if mime_type.blank? + regexp = Regexp.new(mime_type.to_s) + (@synonyms + [ self ]).any? do |synonym| + synonym.to_s =~ regexp + end + end + # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See # ActionController::RequestForgeryProtection. def verify_request? -- cgit v1.2.3