Module: Rack::Accept::Header

Defined in:
lib/grape/middleware/versioner/parse_media_type_patch.rb

Class Method Summary collapse

Class Method Details

.parse_media_type(media_type) ⇒ Object


6
7
8
9
10
# File 'lib/grape/middleware/versioner/parse_media_type_patch.rb', line 6

def parse_media_type(media_type)
  # see http://tools.ietf.org/html/rfc6838#section-4.2 for allowed characters in media type names
  m = media_type.to_s.match(%r{^([a-z*]+)\/([a-z0-9*\&\^\-_#\$!.+]+)(?:;([a-z0-9=;]+))?$})
  m ? [m[1], m[2], m[3] || ''] : []
end