mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 23:08:25 +08:00
DEV: Replace custom Onebox symbolize_keys implementation with ActiveSupport (#23828)
We have a custom implementation of #symbolize_keys in our Onebox helpers. This is likely a legacy from when Onebox was a standalone gem. This change replaces all usages with either #deep_symbolize_keys from ActiveSupport, or appropriate option to the JSON parser gem used.
This commit is contained in:
@ -9,17 +9,6 @@ module Onebox
|
||||
|
||||
IGNORE_CANONICAL_DOMAINS ||= %w[www.instagram.com medium.com youtube.com]
|
||||
|
||||
def self.symbolize_keys(hash)
|
||||
return {} if hash.nil?
|
||||
|
||||
hash.inject({}) do |result, (key, value)|
|
||||
new_key = key.is_a?(String) ? key.to_sym : key
|
||||
new_value = value.is_a?(Hash) ? symbolize_keys(value) : value
|
||||
result[new_key] = new_value
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def self.clean(html)
|
||||
html.gsub(/<[^>]+>/, " ").gsub(/\n/, "")
|
||||
end
|
||||
|
Reference in New Issue
Block a user