diff --git a/internal/reader/rewrite/rewriter_test.go b/internal/reader/rewrite/rewriter_test.go index b38724e3ce6..8948847f6d3 100644 --- a/internal/reader/rewrite/rewriter_test.go +++ b/internal/reader/rewrite/rewriter_test.go @@ -50,12 +50,12 @@ func TestReplaceTextLinks(t *testing.T) { func TestRewriteWithNoMatchingRule(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Some text.`, + Title: `A title`, + WebContent: `Some text.`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Some text.`, + Title: `A title`, + WebContent: `Some text.`, } Rewriter("https://example.org/article", testEntry, ``) @@ -68,12 +68,12 @@ func TestRewriteWithYoutubeLink(t *testing.T) { config.Opts = config.NewOptions() controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Video Description`, + Title: `A title`, + WebContent: `
Video Description`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Video Description`, + Title: `A title`, + WebContent: `Video Description`, } Rewriter("https://www.youtube.com/watch?v=1234", testEntry, ``) @@ -95,12 +95,12 @@ func TestRewriteWithYoutubeLinkAndCustomEmbedURL(t *testing.T) { } controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Video Description`, + Title: `A title`, + WebContent: `
Video Description`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Video Description`, + Title: `A title`, + WebContent: `Video Description`, } Rewriter("https://www.youtube.com/watch?v=1234", testEntry, ``) @@ -111,12 +111,12 @@ func TestRewriteWithYoutubeLinkAndCustomEmbedURL(t *testing.T) { func TestRewriteWithInexistingCustomRule(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Video Description`, + Title: `A title`, + WebContent: `Video Description`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Video Description`, + Title: `A title`, + WebContent: `Video Description`, } Rewriter("https://www.youtube.com/watch?v=1234", testEntry, `some rule`) @@ -127,12 +127,12 @@ func TestRewriteWithInexistingCustomRule(t *testing.T) { func TestRewriteWithXkcdLink(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.

Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.

`, + Title: `A title`, + WebContent: `
Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.

Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.

`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, + Title: `A title`, + WebContent: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, } Rewriter("https://xkcd.com/1912/", testEntry, ``) @@ -143,12 +143,12 @@ func TestRewriteWithXkcdLink(t *testing.T) { func TestRewriteWithXkcdLinkHtmlInjection(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
<foo>

<foo>

`, + Title: `A title`, + WebContent: `
<foo>

<foo>

`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `<foo>`, + Title: `A title`, + WebContent: `<foo>`, } Rewriter("https://xkcd.com/1912/", testEntry, ``) @@ -159,12 +159,12 @@ func TestRewriteWithXkcdLinkHtmlInjection(t *testing.T) { func TestRewriteWithXkcdLinkAndImageNoTitle(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, + Title: `A title`, + WebContent: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, + Title: `A title`, + WebContent: `Your problem is so terrible, I worry that, if I help you, I risk drawing the attention of whatever god of technology inflicted it on you.`, } Rewriter("https://xkcd.com/1912/", testEntry, ``) @@ -175,12 +175,12 @@ func TestRewriteWithXkcdLinkAndImageNoTitle(t *testing.T) { func TestRewriteWithXkcdLinkAndNoImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `test`, + Title: `A title`, + WebContent: `test`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `test`, + Title: `A title`, + WebContent: `test`, } Rewriter("https://xkcd.com/1912/", testEntry, ``) @@ -191,12 +191,12 @@ func TestRewriteWithXkcdLinkAndNoImage(t *testing.T) { func TestRewriteWithXkcdAndNoImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `test`, + Title: `A title`, + WebContent: `test`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `test`, + Title: `A title`, + WebContent: `test`, } Rewriter("https://xkcd.com/1912/", testEntry, ``) @@ -207,12 +207,12 @@ func TestRewriteWithXkcdAndNoImage(t *testing.T) { func TestRewriteMailtoLink(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `contact [blah blah]`, + Title: `A title`, + WebContent: `contact [blah blah]`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `contact`, + Title: `A title`, + WebContent: `contact`, } Rewriter("https://www.qwantz.com/", testEntry, ``) @@ -223,12 +223,12 @@ func TestRewriteMailtoLink(t *testing.T) { func TestRewriteWithPDFLink(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `PDF
test`, + Title: `A title`, + WebContent: `PDF
test`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `test`, + Title: `A title`, + WebContent: `test`, } Rewriter("https://example.org/document.pdf", testEntry, ``) @@ -239,12 +239,12 @@ func TestRewriteWithPDFLink(t *testing.T) { func TestRewriteWithNoLazyImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -255,12 +255,12 @@ func TestRewriteWithNoLazyImage(t *testing.T) { func TestRewriteWithLazyImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -271,12 +271,12 @@ func TestRewriteWithLazyImage(t *testing.T) { func TestRewriteWithLazyDivImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
`, + Title: `A title`, + WebContent: `
`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -287,12 +287,12 @@ func TestRewriteWithLazyDivImage(t *testing.T) { func TestRewriteWithUnknownLazyNoScriptImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `ImageFallback`, + Title: `A title`, + WebContent: `ImageFallback`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -303,12 +303,12 @@ func TestRewriteWithUnknownLazyNoScriptImage(t *testing.T) { func TestRewriteWithLazySrcset(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -319,12 +319,12 @@ func TestRewriteWithLazySrcset(t *testing.T) { func TestRewriteWithImageAndLazySrcset(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Image`, + Title: `A title`, + WebContent: `Image`, } Rewriter("https://example.org/article", testEntry, "add_dynamic_image") @@ -335,12 +335,12 @@ func TestRewriteWithImageAndLazySrcset(t *testing.T) { func TestNewLineRewriteRule(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `A
B
C`, + Title: `A title`, + WebContent: `A
B
C`, } testEntry := &model.Entry{ - Title: `A title`, - Content: "A\nB\nC", + Title: `A title`, + WebContent: "A\nB\nC", } Rewriter("https://example.org/article", testEntry, "nl2br") @@ -351,12 +351,12 @@ func TestNewLineRewriteRule(t *testing.T) { func TestConvertTextLinkRewriteRule(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Test: http://example.org/a/b`, + Title: `A title`, + WebContent: `Test: http://example.org/a/b`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Test: http://example.org/a/b`, + Title: `A title`, + WebContent: `Test: http://example.org/a/b`, } Rewriter("https://example.org/article", testEntry, "convert_text_link") @@ -367,12 +367,12 @@ func TestConvertTextLinkRewriteRule(t *testing.T) { func TestMediumImage(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `Image for post`, + Title: `A title`, + WebContent: `Image for post`, } testEntry := &model.Entry{ Title: `A title`, - Content: ` + WebContent: `
@@ -393,7 +393,7 @@ func TestMediumImage(t *testing.T) { `, } Rewriter("https://example.org/article", testEntry, "fix_medium_images") - testEntry.Content = strings.TrimSpace(testEntry.Content) + testEntry.WebContent = strings.TrimSpace(testEntry.WebContent) if !reflect.DeepEqual(testEntry, controlEntry) { t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry) @@ -402,15 +402,15 @@ func TestMediumImage(t *testing.T) { func TestRewriteNoScriptImageWithoutNoScriptTag(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
The beautiful MDN logo.
MDN Logo
`, + Title: `A title`, + WebContent: `
The beautiful MDN logo.
MDN Logo
`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
The beautiful MDN logo.
MDN Logo
`, + Title: `A title`, + WebContent: `
The beautiful MDN logo.
MDN Logo
`, } Rewriter("https://example.org/article", testEntry, "use_noscript_figure_images") - testEntry.Content = strings.TrimSpace(testEntry.Content) + testEntry.WebContent = strings.TrimSpace(testEntry.WebContent) if !reflect.DeepEqual(testEntry, controlEntry) { t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry) @@ -419,15 +419,15 @@ func TestRewriteNoScriptImageWithoutNoScriptTag(t *testing.T) { func TestRewriteNoScriptImageWithNoScriptTag(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
MDN Logo
`, + Title: `A title`, + WebContent: `
MDN Logo
`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
The beautiful MDN logo.
MDN Logo
`, + Title: `A title`, + WebContent: `
The beautiful MDN logo.
MDN Logo
`, } Rewriter("https://example.org/article", testEntry, "use_noscript_figure_images") - testEntry.Content = strings.TrimSpace(testEntry.Content) + testEntry.WebContent = strings.TrimSpace(testEntry.WebContent) if !reflect.DeepEqual(testEntry, controlEntry) { t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry) @@ -436,12 +436,12 @@ func TestRewriteNoScriptImageWithNoScriptTag(t *testing.T) { func TestRewriteReplaceCustom(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: ``, + Title: `A title`, + WebContent: ``, } testEntry := &model.Entry{ - Title: `A title`, - Content: ``, + Title: `A title`, + WebContent: ``, } Rewriter("https://example.org/article", testEntry, `replace("article/(.*).svg"|"article/$1.png")`) @@ -452,12 +452,12 @@ func TestRewriteReplaceCustom(t *testing.T) { func TestRewriteRemoveCustom(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem Ipsum Super important info
`, + Title: `A title`, + WebContent: `
Lorem Ipsum Super important info
`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem Ipsum I dont want to see thisSuper important info
`, + Title: `A title`, + WebContent: `
Lorem Ipsum I dont want to see thisSuper important info
`, } Rewriter("https://example.org/article", testEntry, `remove(".spam, .ads:not(.keep)")`) @@ -468,12 +468,12 @@ func TestRewriteRemoveCustom(t *testing.T) { func TestRewriteAddCastopodEpisode(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Episode Description`, + Title: `A title`, + WebContent: `
Episode Description`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `Episode Description`, + Title: `A title`, + WebContent: `Episode Description`, } Rewriter("https://podcast.demo/@demo/episodes/test", testEntry, `add_castopod_episode`) @@ -484,12 +484,12 @@ func TestRewriteAddCastopodEpisode(t *testing.T) { func TestRewriteBase64Decode(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `This is some base64 encoded content`, + Title: `A title`, + WebContent: `This is some base64 encoded content`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `VGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=`, + Title: `A title`, + WebContent: `VGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=`, } Rewriter("https://example.org/article", testEntry, `base64_decode`) @@ -500,12 +500,12 @@ func TestRewriteBase64Decode(t *testing.T) { func TestRewriteBase64DecodeInHTML(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem Ipsum not valid base64This is some base64 encoded content
`, + Title: `A title`, + WebContent: `
Lorem Ipsum not valid base64This is some base64 encoded content
`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem Ipsum not valid base64VGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=
`, + Title: `A title`, + WebContent: `
Lorem Ipsum not valid base64VGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=
`, } Rewriter("https://example.org/article", testEntry, `base64_decode`) @@ -516,12 +516,12 @@ func TestRewriteBase64DecodeInHTML(t *testing.T) { func TestRewriteBase64DecodeArgs(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem IpsumThis is some base64 encoded content
`, + Title: `A title`, + WebContent: `
Lorem IpsumThis is some base64 encoded content
`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `
Lorem IpsumVGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=
`, + Title: `A title`, + WebContent: `
Lorem IpsumVGhpcyBpcyBzb21lIGJhc2U2NCBlbmNvZGVkIGNvbnRlbnQ=
`, } Rewriter("https://example.org/article", testEntry, `base64_decode(".base64")`) @@ -532,12 +532,12 @@ func TestRewriteBase64DecodeArgs(t *testing.T) { func TestRewriteRemoveTables(t *testing.T) { controlEntry := &model.Entry{ - Title: `A title`, - Content: `

Test

Hello World!

Test

`, + Title: `A title`, + WebContent: `

Test

Hello World!

Test

`, } testEntry := &model.Entry{ - Title: `A title`, - Content: `

Test

Hello World!

Test

`, + Title: `A title`, + WebContent: `

Test

Hello World!

Test

`, } Rewriter("https://example.org/article", testEntry, `remove_tables`) @@ -548,12 +548,12 @@ func TestRewriteRemoveTables(t *testing.T) { func TestRemoveClickbait(t *testing.T) { controlEntry := &model.Entry{ - Title: `This Is Amazing`, - Content: `Some description`, + Title: `This Is Amazing`, + WebContent: `Some description`, } testEntry := &model.Entry{ - Title: `THIS IS AMAZING`, - Content: `Some description`, + Title: `THIS IS AMAZING`, + WebContent: `Some description`, } Rewriter("https://example.org/article", testEntry, `remove_clickbait`)