mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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:
@@ -76,7 +76,7 @@ module Onebox
|
||||
script = page.at_css('script[type="application/ld+json"]')
|
||||
|
||||
if json_string = script&.text
|
||||
@og_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(json_string))
|
||||
@og_data = ::MultiJson.load(json_string, symbolize_keys: true)
|
||||
else
|
||||
@og_data = {}
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ module Onebox
|
||||
rescue StandardError
|
||||
"{}"
|
||||
end
|
||||
oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
|
||||
oembed_data = ::MultiJson.load(response, symbolize_keys: true)
|
||||
imgur_data_id = Nokogiri.HTML(oembed_data[:html]).xpath("//blockquote").attr("data-id")
|
||||
imgur_data_id.to_s[%r{a/}]
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ module Onebox
|
||||
|
||||
def oembed_data
|
||||
response = Onebox::Helpers.fetch_response("https://vimeo.com/api/oembed.json?url=#{url}")
|
||||
@oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
|
||||
@oembed_data = ::MultiJson.load(response, symbolize_keys: true)
|
||||
rescue StandardError
|
||||
"{}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user