1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Add data-srcset support to "add_dynamic_image rewrite" rewrite rule

This commit is contained in:
Artémis 2021-10-23 03:12:23 +02:00 committed by GitHub
parent d45e1b3bed
commit b585dab6b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View file

@ -176,6 +176,26 @@ func TestRewriteWithUnknownLazyNoScriptImage(t *testing.T) {
}
}
func TestRewriteWithLazySrcset(t *testing.T) {
description := `<img srcset="" data-srcset="https://example.org/image.jpg" alt="Image">`
output := Rewriter("https://example.org/article", description, "add_dynamic_image")
expected := `<img srcset="https://example.org/image.jpg" data-srcset="https://example.org/image.jpg" alt="Image"/>`
if expected != output {
t.Errorf(`Not expected output: got "%s" instead of "%s"`, output, expected)
}
}
func TestRewriteWithImageAndLazySrcset(t *testing.T) {
description := `<img src="meow" srcset="" data-srcset="https://example.org/image.jpg" alt="Image">`
output := Rewriter("https://example.org/article", description, "add_dynamic_image")
expected := `<img src="meow" srcset="https://example.org/image.jpg" data-srcset="https://example.org/image.jpg" alt="Image"/>`
if expected != output {
t.Errorf(`Not expected output: got "%s" instead of "%s"`, output, expected)
}
}
func TestNewLineRewriteRule(t *testing.T) {
description := "A\nB\nC"
output := Rewriter("https://example.org/article", description, "nl2br")