Browse Source

Ignore webmention title if it's a prefix of the content

Fix #4
master
Jan-Lukas Else 3 weeks ago
parent
commit
674417cae9
  1. 4
      webmentionVerification.go
  2. 2
      webmentionVerification_test.go

4
webmentionVerification.go

@ -211,6 +211,10 @@ func (a *goBlog) verifyReader(m *mention, body io.Reader) error {
m.Title = title.Text()
}
}
// Reset title if it's just a prefix of the content
if m.Title != "" && strings.HasPrefix(m.Content, m.Title) {
m.Title = ""
}
return nil
}

2
webmentionVerification_test.go

@ -99,7 +99,7 @@ func Test_verifyMentionBidgy(t *testing.T) {
require.Equal(t, "https://example.org/walks/2021/11/9k-local-run", m.Target)
require.Equal(t, "https://example.com/abc", m.Source)
require.Equal(t, "https://example.net/notice/ADYb7HhxE6UzPpfFiK", m.Url)
require.Equal(t, "comment test", m.Title)
require.Equal(t, "", m.Title)
require.Equal(t, "comment test", m.Content)
require.Equal(t, "m4rk", m.Author)
}

Loading…
Cancel
Save