DEV: Apply suggested changes

This commit is contained in:
Arkshine 2024-06-11 11:54:36 +02:00 committed by Régis Hanol
parent 1fffb236b2
commit 30ae313dec

View File

@ -5,8 +5,7 @@ module HttpUserAgentEncoder
return "" unless user_agent
if user_agent.encoding != Encoding::UTF_8
user_agent = user_agent.encode("utf-8", invalid: :replace, undef: :replace)
user_agent.scrub!
user_agent = user_agent.encode!("utf-8", invalid: :replace, undef: :replace).scrub!
end
user_agent || ""