2024-05-23 21:49:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module HttpUserAgentEncoder
|
|
|
|
def self.ensure_utf8(user_agent)
|
|
|
|
return "" unless user_agent
|
|
|
|
|
|
|
|
if user_agent.encoding != Encoding::UTF_8
|
2024-06-11 05:54:36 -04:00
|
|
|
user_agent = user_agent.encode!("utf-8", invalid: :replace, undef: :replace).scrub!
|
2024-05-23 21:49:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
user_agent || ""
|
|
|
|
end
|
|
|
|
end
|