]> cat aescling's git repositories - mastodon.git/commitdiff
Add workaround for YouTube Shorts links (#17869)
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 25 Mar 2022 18:31:35 +0000 (19:31 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Mar 2022 18:31:35 +0000 (19:31 +0100)
* Add workaround for YouTube Shorts links

* Update link_details_extractor_spec.rb

app/lib/link_details_extractor.rb
spec/lib/link_details_extractor_spec.rb

index fabbd244df9b15fae2bc150408070235d6685ca4..b0c4e4f425e37b3ad1d22a62840895db805b29ea 100644 (file)
@@ -208,7 +208,7 @@ class LinkDetailsExtractor
   end
 
   def valid_url_or_nil(str, same_origin_only: false)
-    return if str.blank?
+    return if str.blank? || str == 'null'
 
     url = @original_url + Addressable::URI.parse(str)
 
index 84bb4579caae4d3e04fa9a07bd3b1d9a83ba142a..7ea867c614a150ee875b261de7e7aac188df9730 100644 (file)
@@ -25,6 +25,14 @@ RSpec.describe LinkDetailsExtractor do
         expect(subject.canonical_url).to eq 'https://foo.com/article'
       end
     end
+
+    context 'when canonical URL is set to "null"' do
+      let(:html) { '<!doctype html><link rel="canonical" href="null" />' }
+
+      it 'ignores the canonical URLs' do
+        expect(subject.canonical_url).to eq original_url
+      end
+    end
   end
 
   context 'when structured data is present' do