Skip to content

Commit

Permalink
Do no rewrite Youtube description twice in "add_youtube_video" rule
Browse files Browse the repository at this point in the history
This is already done before in <media:description>.
  • Loading branch information
fguillot committed Dec 1, 2019
1 parent 6291b59 commit 120d6ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion reader/rewrite/rewrite_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func addYoutubeVideo(entryURL, entryContent string) string {

if len(matches) == 2 {
video := `<iframe width="650" height="350" frameborder="0" src="https://www.youtube-nocookie.com/embed/` + matches[1] + `" allowfullscreen></iframe>`
return video + "<p>" + replaceLineFeeds(replaceTextLinks(entryContent)) + "</p>"
return video + `<br>` + entryContent
}
return entryContent
}
Expand Down
4 changes: 2 additions & 2 deletions reader/rewrite/rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestRewriteWithNoMatchingRule(t *testing.T) {
}

func TestRewriteWithYoutubeLink(t *testing.T) {
output := Rewriter("https://www.youtube.com/watch?v=1234", "Video Description\nhttp://example.org/path", ``)
expected := `<iframe width="650" height="350" frameborder="0" src="https://www.youtube-nocookie.com/embed/1234" allowfullscreen></iframe><p>Video Description<br><a href="http://example.org/path">http://example.org/path</a></p>`
output := Rewriter("https://www.youtube.com/watch?v=1234", "Video Description", ``)
expected := `<iframe width="650" height="350" frameborder="0" src="https://www.youtube-nocookie.com/embed/1234" allowfullscreen></iframe><br>Video Description`

if expected != output {
t.Errorf(`Not expected output: got "%s" instead of "%s"`, output, expected)
Expand Down

0 comments on commit 120d6ec

Please sign in to comment.