forked from wgroeneveld/go-jamming
fix microformat parsing author name fails for complicated mf
parent
f61bda5c5a
commit
8d415d022c
|
@ -222,6 +222,9 @@ func DetermineAuthorName(hEntry *microformats.Microformat) string {
|
|||
if authorName == "" {
|
||||
authorName = Str(hEntry, "author")
|
||||
}
|
||||
if authorName == "" {
|
||||
authorName = Str(hEntry, "name")
|
||||
}
|
||||
return authorName
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"willnorris.com/go/microformats"
|
||||
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"brainbaking.com/go-jamming/mocks"
|
||||
|
@ -311,6 +313,30 @@ func TestReceiveTargetThatDoesNotPointToTheSourceDoesNothing(t *testing.T) {
|
|||
assert.Empty(t, repo.GetAllToModerate("brainbaking.com").Data)
|
||||
}
|
||||
|
||||
func TestConvertBodyToIndiewebDataWithComplicatedDataStillFindsName(t *testing.T) {
|
||||
wm := mf.Mention{
|
||||
Source: "https://pauho.net/2022/05/04/662325/",
|
||||
Target: "https://brainbaking.com/post/2022/04/cool-things-people-do-with-their-blogs/",
|
||||
}
|
||||
cnf := &common.Config{
|
||||
AllowedWebmentionSources: []string{
|
||||
"brainbaking.com",
|
||||
},
|
||||
}
|
||||
|
||||
recv := &Receiver{
|
||||
Conf: cnf,
|
||||
}
|
||||
src, err := ioutil.ReadFile("../../../mocks/indieweb-complicated-data.html")
|
||||
assert.NoError(t, err)
|
||||
|
||||
body := string(src)
|
||||
data := microformats.Parse(strings.NewReader(body), wm.SourceUrl())
|
||||
indieweb := recv.convertBodyToIndiewebData(body, wm, data)
|
||||
|
||||
assert.Equal(t, "Paul Houlihan", indieweb.Author.Name)
|
||||
}
|
||||
|
||||
func TestProcessSourceBodyAnonymizesBothAuthorPictureAndNameIfComingFromSilo(t *testing.T) {
|
||||
wm := mf.Mention{
|
||||
Source: "https://brid.gy/post/twitter/ChrisAldrich/1387130900962443264",
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue