fix: pass down domain to comment for author URLs
This commit is contained in:
parent
d935ce72f6
commit
f1370c29b6
@ -137,7 +137,7 @@ func ViewQuestion(c *gin.Context) {
|
||||
|
||||
newFilteredQuestion.ShortenedBody = shortenedBody
|
||||
|
||||
comments := utils.FindAndReturnComments(questionBodyParentHTML, questionPostLayout)
|
||||
comments := utils.FindAndReturnComments(questionBodyParentHTML, domain, questionPostLayout)
|
||||
newFilteredQuestion.Comments = comments
|
||||
|
||||
// parse any code blocks and highlight them
|
||||
@ -256,7 +256,7 @@ func ViewQuestion(c *gin.Context) {
|
||||
answerBodyHTML = strings.Replace(answerBodyHTML, codeBlock, highlightedCodeBlock, 1)
|
||||
}
|
||||
|
||||
comments = utils.FindAndReturnComments(answerBodyHTML, postLayout)
|
||||
comments = utils.FindAndReturnComments(answerBodyHTML, domain, postLayout)
|
||||
|
||||
newFilteredAnswer.Comments = comments
|
||||
newFilteredAnswer.Body = template.HTML(utils.ReplaceImgTags(answerBodyHTML))
|
||||
|
@ -8,4 +8,5 @@ type FilteredComment struct {
|
||||
AuthorName string
|
||||
AuthorURL string
|
||||
Upvotes string
|
||||
Domain string
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (comments []types.FilteredComment) {
|
||||
func FindAndReturnComments(inHtml, domain string, postLayout *goquery.Selection) (comments []types.FilteredComment) {
|
||||
|
||||
commentsComponent := postLayout.Find("div.js-post-comments-component")
|
||||
|
||||
@ -54,6 +54,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen
|
||||
AuthorName: commentAuthor.Text(),
|
||||
AuthorURL: commentAuthorURL,
|
||||
Upvotes: commentScore,
|
||||
Domain: domain,
|
||||
}
|
||||
|
||||
comments = append(comments, newFilteredComment)
|
||||
|
@ -19,7 +19,7 @@
|
||||
<div class="comment-author">
|
||||
Commented {{ $comment.Timestamp }} by
|
||||
<a
|
||||
href="https://stackoverflow.com{{ $comment.AuthorURL }}"
|
||||
href="https://{{ $comment.Domain }}{{ $comment.AuthorURL }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ $comment.AuthorName }}</a
|
||||
|
Loading…
x
Reference in New Issue
Block a user