@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.
- package/dist/browser/index.js +22 -14
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +23 -15
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +22 -14
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -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
|
|
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';
|
|
@@ -1401,7 +1401,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
|
|
|
1401
1401
|
traverse(doc, forApp, 0, webp, { firstImageFound: false }, parentDomain);
|
|
1402
1402
|
output = serializer.serializeToString(doc);
|
|
1403
1403
|
} catch (fallbackError) {
|
|
1404
|
-
const escapedContent =
|
|
1404
|
+
const escapedContent = he2.encode(output || md.render(input));
|
|
1405
1405
|
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
@@ -1441,8 +1441,6 @@ function markdown2Html(obj, forApp = true, webp = false, parentDomain = "ecency.
|
|
|
1441
1441
|
cacheSet(key, res);
|
|
1442
1442
|
return res;
|
|
1443
1443
|
}
|
|
1444
|
-
|
|
1445
|
-
// src/catch-post-image.ts
|
|
1446
1444
|
var gifLinkRegex = /\.(gif)$/i;
|
|
1447
1445
|
function isGifLink(link) {
|
|
1448
1446
|
return gifLinkRegex.test(link);
|
|
@@ -1459,12 +1457,20 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1459
1457
|
}
|
|
1460
1458
|
}
|
|
1461
1459
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
1462
|
-
|
|
1463
|
-
|
|
1460
|
+
const decodedImage = he2.decode(meta.image);
|
|
1461
|
+
if (isGifLink(decodedImage)) {
|
|
1462
|
+
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1464
1463
|
}
|
|
1465
|
-
return proxifyImageSrc(
|
|
1464
|
+
return proxifyImageSrc(decodedImage, width, height, format);
|
|
1466
1465
|
}
|
|
1467
1466
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
1467
|
+
if (typeof meta.image[0] === "string") {
|
|
1468
|
+
const decodedImage = he2.decode(meta.image[0]);
|
|
1469
|
+
if (isGifLink(decodedImage)) {
|
|
1470
|
+
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1471
|
+
}
|
|
1472
|
+
return proxifyImageSrc(decodedImage, width, height, format);
|
|
1473
|
+
}
|
|
1468
1474
|
if (isGifLink(meta.image[0])) {
|
|
1469
1475
|
return proxifyImageSrc(meta.image[0], 0, 0, format);
|
|
1470
1476
|
}
|
|
@@ -1481,10 +1487,11 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1481
1487
|
if (!src) {
|
|
1482
1488
|
return null;
|
|
1483
1489
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1490
|
+
const decodedSrc = he2.decode(src);
|
|
1491
|
+
if (isGifLink(decodedSrc)) {
|
|
1492
|
+
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1486
1493
|
}
|
|
1487
|
-
return proxifyImageSrc(
|
|
1494
|
+
return proxifyImageSrc(decodedSrc, width, height, format);
|
|
1488
1495
|
}
|
|
1489
1496
|
return null;
|
|
1490
1497
|
}
|
|
@@ -1501,10 +1508,11 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
|
|
|
1501
1508
|
if (!src) {
|
|
1502
1509
|
return null;
|
|
1503
1510
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1511
|
+
const decodedSrc = he2.decode(src);
|
|
1512
|
+
if (isGifLink(decodedSrc)) {
|
|
1513
|
+
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1506
1514
|
}
|
|
1507
|
-
return proxifyImageSrc(
|
|
1515
|
+
return proxifyImageSrc(decodedSrc, width, height, format);
|
|
1508
1516
|
}
|
|
1509
1517
|
return null;
|
|
1510
1518
|
}
|
|
@@ -1593,7 +1601,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
|
|
|
1593
1601
|
text2 = joint(text2.split(" "), length);
|
|
1594
1602
|
}
|
|
1595
1603
|
if (text2) {
|
|
1596
|
-
text2 =
|
|
1604
|
+
text2 = he2.decode(text2);
|
|
1597
1605
|
}
|
|
1598
1606
|
return text2;
|
|
1599
1607
|
}
|