Module: Rack::Accept::Header

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

Constant Summary collapse

ALLOWED_CHARACTERS =
%r{^([a-z*]+)\/([a-z0-9*\&\^\-_#\$!.+]+)(?:;([a-z0-9=;]+))?$}.freeze

Class Method Summary collapse

Class Method Details

.parse_media_type(media_type) ⇒ Object


9
10
11
12
13
# File 'lib/grape/middleware/versioner/parse_media_type_patch.rb', line 9

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&.match(ALLOWED_CHARACTERS)
  m ? [m[1], m[2], m[3] || ''] : []
end