lib/http/accept/charsets.rb in http-accept-1.7.0 vs lib/http/accept/charsets.rb in http-accept-2.1.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+#
# Copyright (C) 2016, Matthew Kerwin <matthew@kerwin.net.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@@ -63,12 +65,10 @@
HTTP_ACCEPT_CHARSET = 'HTTP_ACCEPT_CHARSET'.freeze
WILDCARD_CHARSET = Charset.new('*', nil).freeze
# Parse the list of browser preferred charsets and return ordered by priority.
def self.browser_preferred_charsets(env)
- if accept_charsets = env[HTTP_ACCEPT_CHARSET]
- accept_charsets.strip!
-
+ if accept_charsets = env[HTTP_ACCEPT_CHARSET]&.strip
if accept_charsets.empty?
# https://tools.ietf.org/html/rfc7231#section-5.3.3 :
#
# Accept-Charset = 1#( ( charset / "*" ) [ weight ] )
#