@ecency/render-helper 2.4.12 → 2.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ var multihash = require('multihashes');
6
6
  var querystring = require('querystring');
7
7
  var remarkable = require('remarkable');
8
8
  var linkify$1 = require('remarkable/linkify');
9
- var he = require('he');
9
+ var he2 = require('he');
10
10
  var htmlparser2 = require('htmlparser2');
11
11
  var domSerializerModule = require('dom-serializer');
12
12
  var lruCache = require('lru-cache');
@@ -34,7 +34,7 @@ function _interopNamespace(e) {
34
34
  var xss__default = /*#__PURE__*/_interopDefault(xss);
35
35
  var multihash__default = /*#__PURE__*/_interopDefault(multihash);
36
36
  var querystring__default = /*#__PURE__*/_interopDefault(querystring);
37
- var he__default = /*#__PURE__*/_interopDefault(he);
37
+ var he2__default = /*#__PURE__*/_interopDefault(he2);
38
38
  var htmlparser2__namespace = /*#__PURE__*/_interopNamespace(htmlparser2);
39
39
  var domSerializerModule__namespace = /*#__PURE__*/_interopNamespace(domSerializerModule);
40
40
 
@@ -1433,7 +1433,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
1433
1433
  traverse(doc, forApp, 0, webp, { firstImageFound: false }, parentDomain);
1434
1434
  output = serializer.serializeToString(doc);
1435
1435
  } catch (fallbackError) {
1436
- const escapedContent = he__default.default.encode(output || md.render(input));
1436
+ const escapedContent = he2__default.default.encode(output || md.render(input));
1437
1437
  output = `<p dir="auto">${escapedContent}</p>`;
1438
1438
  }
1439
1439
  }
@@ -1473,8 +1473,6 @@ function markdown2Html(obj, forApp = true, webp = false, parentDomain = "ecency.
1473
1473
  cacheSet(key, res);
1474
1474
  return res;
1475
1475
  }
1476
-
1477
- // src/catch-post-image.ts
1478
1476
  var gifLinkRegex = /\.(gif)$/i;
1479
1477
  function isGifLink(link) {
1480
1478
  return gifLinkRegex.test(link);
@@ -1491,12 +1489,20 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1491
1489
  }
1492
1490
  }
1493
1491
  if (meta && typeof meta.image === "string" && meta.image.length > 0) {
1494
- if (isGifLink(meta.image)) {
1495
- return proxifyImageSrc(meta.image, 0, 0, format);
1492
+ const decodedImage = he2__default.default.decode(meta.image);
1493
+ if (isGifLink(decodedImage)) {
1494
+ return proxifyImageSrc(decodedImage, 0, 0, format);
1496
1495
  }
1497
- return proxifyImageSrc(meta.image, width, height, format);
1496
+ return proxifyImageSrc(decodedImage, width, height, format);
1498
1497
  }
1499
1498
  if (meta && meta.image && !!meta.image.length && meta.image[0]) {
1499
+ if (typeof meta.image[0] === "string") {
1500
+ const decodedImage = he2__default.default.decode(meta.image[0]);
1501
+ if (isGifLink(decodedImage)) {
1502
+ return proxifyImageSrc(decodedImage, 0, 0, format);
1503
+ }
1504
+ return proxifyImageSrc(decodedImage, width, height, format);
1505
+ }
1500
1506
  if (isGifLink(meta.image[0])) {
1501
1507
  return proxifyImageSrc(meta.image[0], 0, 0, format);
1502
1508
  }
@@ -1513,10 +1519,11 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1513
1519
  if (!src) {
1514
1520
  return null;
1515
1521
  }
1516
- if (isGifLink(src)) {
1517
- return proxifyImageSrc(src, 0, 0, format);
1522
+ const decodedSrc = he2__default.default.decode(src);
1523
+ if (isGifLink(decodedSrc)) {
1524
+ return proxifyImageSrc(decodedSrc, 0, 0, format);
1518
1525
  }
1519
- return proxifyImageSrc(src, width, height, format);
1526
+ return proxifyImageSrc(decodedSrc, width, height, format);
1520
1527
  }
1521
1528
  return null;
1522
1529
  }
@@ -1533,10 +1540,11 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
1533
1540
  if (!src) {
1534
1541
  return null;
1535
1542
  }
1536
- if (isGifLink(src)) {
1537
- return proxifyImageSrc(src, 0, 0, format);
1543
+ const decodedSrc = he2__default.default.decode(src);
1544
+ if (isGifLink(decodedSrc)) {
1545
+ return proxifyImageSrc(decodedSrc, 0, 0, format);
1538
1546
  }
1539
- return proxifyImageSrc(src, width, height, format);
1547
+ return proxifyImageSrc(decodedSrc, width, height, format);
1540
1548
  }
1541
1549
  return null;
1542
1550
  }
@@ -1625,7 +1633,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
1625
1633
  text2 = joint(text2.split(" "), length);
1626
1634
  }
1627
1635
  if (text2) {
1628
- text2 = he__default.default.decode(text2);
1636
+ text2 = he2__default.default.decode(text2);
1629
1637
  }
1630
1638
  return text2;
1631
1639
  }