|
|
@@ -162,3 +162,53 @@ func TestEspaceAttributes(t *testing.T) {
|
|
|
t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestReplaceYoutubeURL(t *testing.T) {
|
|
|
+ input := `<iframe src="http://www.youtube.com/embed/test123?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent"></iframe>`
|
|
|
+ expected := `<iframe src="https://www.youtube-nocookie.com/embed/test123?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent"></iframe>`
|
|
|
+ output := Sanitize("http://example.org/", input)
|
|
|
+
|
|
|
+ if expected != output {
|
|
|
+ t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestReplaceSecureYoutubeURL(t *testing.T) {
|
|
|
+ input := `<iframe src="https://www.youtube.com/embed/test123"></iframe>`
|
|
|
+ expected := `<iframe src="https://www.youtube-nocookie.com/embed/test123"></iframe>`
|
|
|
+ output := Sanitize("http://example.org/", input)
|
|
|
+
|
|
|
+ if expected != output {
|
|
|
+ t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestReplaceSecureYoutubeURLWithParameters(t *testing.T) {
|
|
|
+ input := `<iframe src="https://www.youtube.com/embed/test123?rel=0&controls=0"></iframe>`
|
|
|
+ expected := `<iframe src="https://www.youtube-nocookie.com/embed/test123?rel=0&controls=0"></iframe>`
|
|
|
+ output := Sanitize("http://example.org/", input)
|
|
|
+
|
|
|
+ if expected != output {
|
|
|
+ t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestReplaceYoutubeURLAlreadyReplaced(t *testing.T) {
|
|
|
+ input := `<iframe src="https://www.youtube-nocookie.com/embed/test123?rel=0&controls=0"></iframe>`
|
|
|
+ expected := `<iframe src="https://www.youtube-nocookie.com/embed/test123?rel=0&controls=0"></iframe>`
|
|
|
+ output := Sanitize("http://example.org/", input)
|
|
|
+
|
|
|
+ if expected != output {
|
|
|
+ t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestReplaceIframeURL(t *testing.T) {
|
|
|
+ input := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0"></iframe>`
|
|
|
+ expected := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0"></iframe>`
|
|
|
+ output := Sanitize("http://example.org/", input)
|
|
|
+
|
|
|
+ if expected != output {
|
|
|
+ t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
|
|
+ }
|
|
|
+}
|