Преглед изворни кода

test(sanitizer): add test case to cover Vimeo iframe rewrite without query string

Frédéric Guillot пре 10 месеци
родитељ
комит
6af4d69c39
1 измењених фајлова са 12 додато и 2 уклоњено
  1. 12 2
      internal/reader/sanitizer/sanitizer_test.go

+ 12 - 2
internal/reader/sanitizer/sanitizer_test.go

@@ -818,13 +818,23 @@ func TestReplaceYoutubeURLWithCustomURL(t *testing.T) {
 	}
 }
 
-func TestReplaceIframeVimedoDNTURL(t *testing.T) {
+func TestVimeoIframeRewriteWithQueryString(t *testing.T) {
 	input := `<iframe src="https://player.vimeo.com/video/123456?title=0&amp;byline=0"></iframe>`
 	expected := `<iframe src="https://player.vimeo.com/video/123456?title=0&amp;byline=0&amp;dnt=1" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>`
 	output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
 
 	if expected != output {
-		t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
+		t.Errorf(`Wrong output: %q != %q`, expected, output)
+	}
+}
+
+func TestVimeoIframeRewriteWithoutQueryString(t *testing.T) {
+	input := `<iframe src="https://player.vimeo.com/video/123456"></iframe>`
+	expected := `<iframe src="https://player.vimeo.com/video/123456?dnt=1" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>`
+	output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
+
+	if expected != output {
+		t.Errorf(`Wrong output: %q != %q`, expected, output)
 	}
 }