mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-29 18:18:13 +00:00
refactor: simplify author parsing logic
This commit is contained in:
parent
9d28ee483c
commit
64302c9334
1 changed files with 5 additions and 13 deletions
|
@ -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…
Add table
Reference in a new issue