refactor: simplify author parsing logic
This commit is contained in:
parent
9d28ee483c
commit
64302c9334
@ -217,22 +217,14 @@ func ViewQuestion(c *gin.Context) {
|
|||||||
answerTimestamp := ""
|
answerTimestamp := ""
|
||||||
|
|
||||||
answerFooter.Find("div.post-signature").Each(func(i int, s *goquery.Selection) {
|
answerFooter.Find("div.post-signature").Each(func(i int, s *goquery.Selection) {
|
||||||
answerAuthorDetails := s.Find("div.user-details")
|
questionAuthorDetails := questionMetadata.Find("div.user-details")
|
||||||
|
|
||||||
if answerAuthorDetails.Length() == 0 {
|
if questionAuthorDetails.Length() > 0 {
|
||||||
return
|
questionAuthor := questionAuthorDetails.Find("a").First()
|
||||||
|
newFilteredQuestion.AuthorName = html.EscapeString(questionAuthor.Text())
|
||||||
|
newFilteredQuestion.AuthorURL = html.EscapeString(questionAuthor.AttrOr("href", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
if answerAuthorDetails.Length() > 1 {
|
|
||||||
if i == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
answerAuthor := answerAuthorDetails.Find("a").First()
|
|
||||||
|
|
||||||
answerAuthorURL = html.EscapeString(answerAuthor.AttrOr("href", ""))
|
|
||||||
answerAuthorName = html.EscapeString(answerAuthor.Text())
|
|
||||||
answerTimestamp = html.EscapeString(s.Find("span.relativetime").Text())
|
answerTimestamp = html.EscapeString(s.Find("span.relativetime").Text())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user