aboutsummaryrefslogtreecommitdiff
path: root/src/mixins/postUtils.pug
diff options
context:
space:
mode:
authorPortableProgrammer <[email protected]>2025-01-04 18:16:31 +0000
committerPortableProgrammer <[email protected]>2025-01-04 18:16:31 +0000
commit9793c5e0ec707b967f770242b22950e1741341a6 (patch)
tree71504a4902193c60d47516d74d1c95b4bdc9ae9f /src/mixins/postUtils.pug
parent0cfd4af340ee14fa92d676b54b25ee66c4d4824c (diff)
Detect `preview.redd.it`, `i.redd.it`, and `i.imgur.com` inline links and expand them to image tags in card view and comments.
Diffstat (limited to 'src/mixins/postUtils.pug')
-rw-r--r--src/mixins/postUtils.pug5
1 files changed, 3 insertions, 2 deletions
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) => {