Skip to content

Commit

Permalink
'string'[0, index] is faster and more eco-friendly than 'string'.spli…
Browse files Browse the repository at this point in the history
…t.first
  • Loading branch information
amatsuda committed Dec 17, 2022
1 parent 40b1c60 commit 78599ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion actionpack/lib/action_dispatch/http/mime_type.rb
Expand Up @@ -171,7 +171,9 @@ def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], s

def parse(accept_header)
if !accept_header.include?(",")
accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first
if (index = accept_header.index(PARAMETER_SEPARATOR_REGEXP))
accept_header = accept_header[0, index]
end
return [] unless accept_header
parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact
else
Expand Down

0 comments on commit 78599ba

Please sign in to comment.