+2
-1
src/mixins/comment.pug
+2
-1
src/mixins/comment.pug
···
1
1
include ../utils
2
+
include postUtils
2
3
3
4
mixin infoContainer(data, next_id, prev_id)
4
5
- var hats = (data.is_submitter?['op']:[]).concat(data.distinguished=="moderator"?['mod']:[])
···
51
52
summary.expand-comments
52
53
+infoContainer(data, next_id, prev_id)
53
54
div.comment-body
54
-
!= data.body_html
55
+
!= convertInlineImageLinks(data.body_html)
55
56
if hasReplyData
56
57
div.replies
57
58
- var total = data.replies.data.children.length
+3
-2
src/mixins/postUtils.pug
+3
-2
src/mixins/postUtils.pug
···
53
53
}
54
54
-
55
55
function convertInlineImageLinks(html) {
56
-
// Find all anchors that href to https://preview.redd.it
57
-
const expression = /<a href="https:\/\/preview\.redd\.it.*?">(.*?)<\/a>/g;
56
+
// Find all anchors that href to preview.redd.it, i.redd.it, i.imgur.com
57
+
// and contain just a link to the same href
58
+
const expression = /<a href="(http[s]?:\/\/(?:preview\.redd\.it|i\.redd\.it|i\.imgur\.com).*?)">\1?<\/a>/g;
58
59
const matches = html.matchAll(expression);
59
60
var result = html;
60
61
matches.forEach((match) => {