mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
15 lines
319 B
Ruby
15 lines
319 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module HttpUserAgentEncoder
|
||
|
def self.ensure_utf8(user_agent)
|
||
|
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!
|
||
|
end
|
||
|
|
||
|
user_agent || ""
|
||
|
end
|
||
|
end
|