Skip to content

Commit

Permalink
Fix error when accept-language contains ,,
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonBarnabe committed Sep 18, 2024
1 parent b77d967 commit b50e95d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/concerns/localized_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def detect_locale_code
def parse_accept_language(value)
return [] if value.nil?

return value.split(',').map do |r|
return value.split(',').filter_map do |r|
locale = r.split(';').first.strip
next nil unless locale

# make sure the region is uppercase
locale_parts = r.split(';').first.strip.split('-', 2)
locale_parts = locale.split('-', 2)
locale_parts[1].upcase! if locale_parts.length > 1
next locale_parts.join('-')
end
Expand Down

0 comments on commit b50e95d

Please sign in to comment.