Fix: Don't return mentions when no address provided

This commit is contained in:
Jan-Lukas Else 2021-11-22 16:56:40 +01:00
parent 783afc1c3e
commit affa7d7d54
2 changed files with 6 additions and 0 deletions

View File

@ -287,6 +287,9 @@ func (db *database) getWebmentions(config *webmentionsRequestConfig) ([]*mention
}
func (db *database) getWebmentionsByAddress(address string) []*mention {
if address == "" {
return nil
}
mentions, _ := db.getWebmentions(&webmentionsRequestConfig{
target: address,
status: webmentionStatusApproved,

View File

@ -58,6 +58,9 @@ func Test_webmentions(t *testing.T) {
mentions = app.db.getWebmentionsByAddress("https://example.com/täst")
assert.Len(t, mentions, 0)
mentions = app.db.getWebmentionsByAddress("")
assert.Len(t, mentions, 0)
mentions, err = app.db.getWebmentions(&webmentionsRequestConfig{
sourcelike: "example.net",
})