mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-27 08:14:25 +00:00
Fix handling of inLanguage
attribute in preview card processing (#27423)
This commit is contained in:
parent
8be33d4316
commit
13205b54fd
|
@ -36,7 +36,8 @@ class LinkDetailsExtractor
|
||||||
end
|
end
|
||||||
|
|
||||||
def language
|
def language
|
||||||
json['inLanguage']
|
lang = json['inLanguage']
|
||||||
|
lang.is_a?(Hash) ? (lang['alternateName'] || lang['name']) : lang
|
||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
|
|
|
@ -82,6 +82,10 @@ RSpec.describe LinkDetailsExtractor do
|
||||||
'name' => 'Pet News',
|
'name' => 'Pet News',
|
||||||
'url' => 'https://example.com',
|
'url' => 'https://example.com',
|
||||||
},
|
},
|
||||||
|
'inLanguage' => {
|
||||||
|
name: 'English',
|
||||||
|
alternateName: 'en',
|
||||||
|
},
|
||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,6 +119,12 @@ RSpec.describe LinkDetailsExtractor do
|
||||||
expect(subject.provider_name).to eq 'Pet News'
|
expect(subject.provider_name).to eq 'Pet News'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#language' do
|
||||||
|
it 'returns the language from structured data' do
|
||||||
|
expect(subject.language).to eq 'en'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is wrapped in CDATA tags' do
|
context 'when is wrapped in CDATA tags' do
|
||||||
|
|
Loading…
Reference in a new issue