aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mixins/comment.pug3
-rw-r--r--src/mixins/postUtils.pug5
2 files changed, 5 insertions, 3 deletions
diff --git a/src/mixins/comment.pug b/src/mixins/comment.pug
index 5b6f097..0609587 100644
--- a/src/mixins/comment.pug
+++ b/src/mixins/comment.pug
@@ -1,4 +1,5 @@
1include ../utils 1include ../utils
2include postUtils
2 3
3mixin infoContainer(data, next_id, prev_id) 4mixin infoContainer(data, next_id, prev_id)
4 - var hats = (data.is_submitter?['op']:[]).concat(data.distinguished=="moderator"?['mod']:[]) 5 - var hats = (data.is_submitter?['op']:[]).concat(data.distinguished=="moderator"?['mod']:[])
@@ -51,7 +52,7 @@ mixin comment(com, isfirst, parent_id, next_id, prev_id)
51 summary.expand-comments 52 summary.expand-comments
52 +infoContainer(data, next_id, prev_id) 53 +infoContainer(data, next_id, prev_id)
53 div.comment-body 54 div.comment-body
54 != data.body_html 55 != convertInlineImageLinks(data.body_html)
55 if hasReplyData 56 if hasReplyData
56 div.replies 57 div.replies
57 - var total = data.replies.data.children.length 58 - var total = data.replies.data.children.length
diff --git a/src/mixins/postUtils.pug b/src/mixins/postUtils.pug
index 84add09..b778cbd 100644
--- a/src/mixins/postUtils.pug
+++ b/src/mixins/postUtils.pug
@@ -53,8 +53,9 @@
53 } 53 }
54- 54-
55 function convertInlineImageLinks(html) { 55 function convertInlineImageLinks(html) {
56 // Find all anchors that href to https://preview.redd.it 56 // Find all anchors that href to preview.redd.it, i.redd.it, i.imgur.com
57 const expression = /<a href="https:\/\/preview\.redd\.it.*?">(.*?)<\/a>/g; 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 const matches = html.matchAll(expression); 59 const matches = html.matchAll(expression);
59 var result = html; 60 var result = html;
60 matches.forEach((match) => { 61 matches.forEach((match) => {