Skip to content
Snippets Groups Projects
Unverified Commit ab763c49 authored by David Roetzel's avatar David Roetzel Committed by GitHub
Browse files

Ignore `undefined` as canonical url (#31882)

parent 3d46f478
No related branches found
No related tags found
No related merge requests found
...@@ -225,7 +225,7 @@ class LinkDetailsExtractor ...@@ -225,7 +225,7 @@ class LinkDetailsExtractor
end end
def valid_url_or_nil(str, same_origin_only: false) def valid_url_or_nil(str, same_origin_only: false)
return if str.blank? || str == 'null' return if str.blank? || str == 'null' || str == 'undefined'
url = @original_url + Addressable::URI.parse(str) url = @original_url + Addressable::URI.parse(str)
......
...@@ -33,6 +33,14 @@ RSpec.describe LinkDetailsExtractor do ...@@ -33,6 +33,14 @@ RSpec.describe LinkDetailsExtractor do
expect(subject.canonical_url).to eq original_url expect(subject.canonical_url).to eq original_url
end end
end end
context 'when canonical URL is set to "undefined"' do
let(:url) { 'undefined' }
it 'ignores the canonical URLs' do
expect(subject.canonical_url).to eq original_url
end
end
end end
context 'when only basic metadata is present' do context 'when only basic metadata is present' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment