1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

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

This commit is contained in:
Frédéric Guillot 2025-06-17 17:50:42 -07:00
parent 27015a5e34
commit 0b001edbf6

View file

@ -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>` 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>` 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) output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
if expected != output { 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)
} }
} }