Support JSON-LD named graph (#31288)

This commit is contained in:
Christian Schmidt 2024-08-06 09:52:47 +02:00 committed by GitHub
parent 135493c0b4
commit e9e63ed203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 11 deletions

View file

@ -101,7 +101,9 @@ class LinkDetailsExtractor
end
def json
@json ||= root_array(Oj.load(@data)).compact.find { |obj| SUPPORTED_TYPES.include?(obj['@type']) } || {}
@json ||= root_array(Oj.load(@data))
.map { |node| JSON::LD::API.compact(node, 'https://schema.org') }
.find { |node| SUPPORTED_TYPES.include?(node['type']) } || {}
end
end