summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/post_test.go b/app/post_test.go
index 10b957751..aefc0ea35 100644
--- a/app/post_test.go
+++ b/app/post_test.go
@@ -297,6 +297,34 @@ func TestImageProxy(t *testing.T) {
}
}
+func BenchmarkForceHTMLEncodingToUTF8(b *testing.B) {
+ HTML := `
+ <html>
+ <head>
+ <meta property="og:url" content="https://example.com/apps/mattermost">
+ <meta property="og:image" content="https://images.example.com/image.png">
+ </head>
+ </html>
+ `
+ ContentType := "text/html; utf-8"
+
+ b.Run("with converting", func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ r := forceHTMLEncodingToUTF8(strings.NewReader(HTML), ContentType)
+
+ og := opengraph.NewOpenGraph()
+ og.ProcessHTML(r)
+ }
+ })
+
+ b.Run("without converting", func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ og := opengraph.NewOpenGraph()
+ og.ProcessHTML(strings.NewReader(HTML))
+ }
+ })
+}
+
func TestMakeOpenGraphURLsAbsolute(t *testing.T) {
for name, tc := range map[string]struct {
HTML string