@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.
@@ -4,7 +4,7 @@ import multihash from 'multihashes';
4
4
  import querystring from 'querystring';
5
5
  import { Remarkable } from 'remarkable';
6
6
  import { linkify as linkify$1 } from 'remarkable/linkify';
7
- import he from 'he';
7
+ import he2 from 'he';
8
8
  import * as htmlparser2 from 'htmlparser2';
9
9
  import * as domSerializerModule from 'dom-serializer';
10
10
  import { LRUCache } from 'lru-cache';
@@ -1404,7 +1404,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
1404
1404
  traverse(doc, forApp, 0, webp, { firstImageFound: false }, parentDomain);
1405
1405
  output = serializer.serializeToString(doc);
1406
1406
  } catch (fallbackError) {
1407
- const escapedContent = he.encode(output || md.render(input));
1407
+ const escapedContent = he2.encode(output || md.render(input));
1408
1408
  output = `<p dir="auto">${escapedContent}</p>`;
1409
1409
  }
1410
1410
  }
@@ -1444,8 +1444,6 @@ function markdown2Html(obj, forApp = true, webp = false, parentDomain = "ecency.
1444
1444
  cacheSet(key, res);
1445
1445
  return res;
1446
1446
  }
1447
-
1448
- // src/catch-post-image.ts
1449
1447
  var gifLinkRegex = /\.(gif)$/i;
1450
1448
  function isGifLink(link) {
1451
1449
  return gifLinkRegex.test(link);
@@ -1462,12 +1460,20 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1462
1460
  }
1463
1461
  }
1464
1462
  if (meta && typeof meta.image === "string" && meta.image.length > 0) {
1465
- if (isGifLink(meta.image)) {
1466
- return proxifyImageSrc(meta.image, 0, 0, format);
1463
+ const decodedImage = he2.decode(meta.image);
1464
+ if (isGifLink(decodedImage)) {
1465
+ return proxifyImageSrc(decodedImage, 0, 0, format);
1467
1466
  }
1468
- return proxifyImageSrc(meta.image, width, height, format);
1467
+ return proxifyImageSrc(decodedImage, width, height, format);
1469
1468
  }
1470
1469
  if (meta && meta.image && !!meta.image.length && meta.image[0]) {
1470
+ if (typeof meta.image[0] === "string") {
1471
+ const decodedImage = he2.decode(meta.image[0]);
1472
+ if (isGifLink(decodedImage)) {
1473
+ return proxifyImageSrc(decodedImage, 0, 0, format);
1474
+ }
1475
+ return proxifyImageSrc(decodedImage, width, height, format);
1476
+ }
1471
1477
  if (isGifLink(meta.image[0])) {
1472
1478
  return proxifyImageSrc(meta.image[0], 0, 0, format);
1473
1479
  }
@@ -1484,10 +1490,11 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1484
1490
  if (!src) {
1485
1491
  return null;
1486
1492
  }
1487
- if (isGifLink(src)) {
1488
- return proxifyImageSrc(src, 0, 0, format);
1493
+ const decodedSrc = he2.decode(src);
1494
+ if (isGifLink(decodedSrc)) {
1495
+ return proxifyImageSrc(decodedSrc, 0, 0, format);
1489
1496
  }
1490
- return proxifyImageSrc(src, width, height, format);
1497
+ return proxifyImageSrc(decodedSrc, width, height, format);
1491
1498
  }
1492
1499
  return null;
1493
1500
  }
@@ -1504,10 +1511,11 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
1504
1511
  if (!src) {
1505
1512
  return null;
1506
1513
  }
1507
- if (isGifLink(src)) {
1508
- return proxifyImageSrc(src, 0, 0, format);
1514
+ const decodedSrc = he2.decode(src);
1515
+ if (isGifLink(decodedSrc)) {
1516
+ return proxifyImageSrc(decodedSrc, 0, 0, format);
1509
1517
  }
1510
- return proxifyImageSrc(src, width, height, format);
1518
+ return proxifyImageSrc(decodedSrc, width, height, format);
1511
1519
  }
1512
1520
  return null;
1513
1521
  }
@@ -1596,7 +1604,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
1596
1604
  text2 = joint(text2.split(" "), length);
1597
1605
  }
1598
1606
  if (text2) {
1599
- text2 = he.decode(text2);
1607
+ text2 = he2.decode(text2);
1600
1608
  }
1601
1609
  return text2;
1602
1610
  }