@ecency/render-helper 2.5.7 → 2.5.9
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.d.ts +18 -2
- package/dist/browser/index.js +13 -7
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +13 -7
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +13 -7
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -504,9 +504,11 @@ function setProxyBase(p2) {
|
|
|
504
504
|
function getProxyBase() {
|
|
505
505
|
return proxyBase;
|
|
506
506
|
}
|
|
507
|
+
var PROXY_P_PREFIXES = () => [`${proxyBase}/p/`, "https://images.ecency.com/p/"];
|
|
507
508
|
function extractPHash(url) {
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
const prefix = PROXY_P_PREFIXES().find((p2) => url.startsWith(p2));
|
|
510
|
+
if (prefix) {
|
|
511
|
+
const [hash] = url.slice(prefix.length).split("?");
|
|
510
512
|
return hash.replace(/\.(webp|png)$/, "");
|
|
511
513
|
}
|
|
512
514
|
return null;
|
|
@@ -522,17 +524,18 @@ function getLatestUrl(str) {
|
|
|
522
524
|
const [last] = [...str.replace(/https?:\/\//g, "\n$&").trim().split("\n")].reverse();
|
|
523
525
|
return last;
|
|
524
526
|
}
|
|
525
|
-
function proxifyImageSrc(url, width = 0, height = 0, _format = "match") {
|
|
527
|
+
function proxifyImageSrc(url, width = 0, height = 0, _format = "match", opts = {}) {
|
|
526
528
|
if (!url || typeof url !== "string" || !isValidUrl(url)) {
|
|
527
529
|
return "";
|
|
528
530
|
}
|
|
531
|
+
const routeThroughProxy = width > 0 || height > 0 || !!opts.blur || !!opts.forceProxy;
|
|
529
532
|
if (url.indexOf("https://images.hive.blog/") === 0 && url.indexOf("https://images.hive.blog/D") !== 0) {
|
|
530
533
|
return url.replace("https://images.hive.blog", proxyBase);
|
|
531
534
|
}
|
|
532
535
|
if (url.indexOf("https://steemitimages.com/") === 0 && url.indexOf("https://steemitimages.com/D") !== 0) {
|
|
533
536
|
return url.replace("https://steemitimages.com", proxyBase);
|
|
534
537
|
}
|
|
535
|
-
if (url.indexOf("https://images.ecency.com/") === 0) {
|
|
538
|
+
if (url.indexOf("https://images.ecency.com/") === 0 && !routeThroughProxy) {
|
|
536
539
|
return url.replace("https://images.ecency.com", proxyBase);
|
|
537
540
|
}
|
|
538
541
|
const realUrl = getLatestUrl(url);
|
|
@@ -547,6 +550,9 @@ function proxifyImageSrc(url, width = 0, height = 0, _format = "match") {
|
|
|
547
550
|
if (height > 0) {
|
|
548
551
|
options.height = height;
|
|
549
552
|
}
|
|
553
|
+
if (opts.blur) {
|
|
554
|
+
options.blur = 1;
|
|
555
|
+
}
|
|
550
556
|
const qs = querystring__default.default.stringify(options);
|
|
551
557
|
if (pHash) {
|
|
552
558
|
return `${proxyBase}/p/${pHash}?${qs}`;
|
|
@@ -607,7 +613,7 @@ function img(el, state) {
|
|
|
607
613
|
const base = trimTrailingSlash(getProxyBase());
|
|
608
614
|
const hasAlreadyProxied = src.startsWith(`${base}/p/`) || src.startsWith(`${base}/u/`) || new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/\\d+x\\d+/`).test(src);
|
|
609
615
|
if (shouldReplace && !hasAlreadyProxied) {
|
|
610
|
-
const proxified = proxifyImageSrc(decodedSrc);
|
|
616
|
+
const proxified = proxifyImageSrc(decodedSrc, 0, 0, "match", { forceProxy: true });
|
|
611
617
|
if (proxified) {
|
|
612
618
|
el.setAttribute("src", proxified);
|
|
613
619
|
const srcset = buildSrcSet(decodedSrc);
|
|
@@ -627,7 +633,7 @@ function img(el, state) {
|
|
|
627
633
|
}
|
|
628
634
|
}
|
|
629
635
|
function createImageHTML(src, isLCP) {
|
|
630
|
-
const proxified = proxifyImageSrc(src);
|
|
636
|
+
const proxified = proxifyImageSrc(src, 0, 0, "match", { forceProxy: true });
|
|
631
637
|
if (!proxified) return "";
|
|
632
638
|
const base = trimTrailingSlash(getProxyBase());
|
|
633
639
|
const isAlreadyProxied = src.startsWith(`${base}/u/`) || new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/\\d+x\\d+/`).test(src);
|
|
@@ -1685,7 +1691,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
|
|
|
1685
1691
|
|
|
1686
1692
|
// src/methods/clean-reply.method.ts
|
|
1687
1693
|
function cleanReply(s) {
|
|
1688
|
-
return (s ? s.split("\n").filter((item) => item.toLowerCase().includes("posted using [partiko") === false).filter((item) => item.toLowerCase().includes("posted using [dapplr") === false).filter((item) => item.toLowerCase().includes("posted using [leofinance") === false).filter((item) => item.toLowerCase().includes("posted via [neoxian") === false).filter((item) => item.toLowerCase().includes("posted using [neoxian") === false).filter((item) => item.toLowerCase().includes("posted with [stemgeeks") === false).filter((item) => item.toLowerCase().includes("posted using [bilpcoin") === false).filter((item) => item.toLowerCase().includes("posted using [inleo") === false).filter((item) => item.toLowerCase().includes("posted using [sportstalksocial]") === false).filter((item) => item.toLowerCase().includes("<center><sub>[posted using aeneas.blog") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [proofofbrain.io") === false).filter((item) => item.toLowerCase().includes("<center>posted on [hypnochain") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [weedcash.network") === false).filter((item) => item.toLowerCase().includes("<center>posted on [naturalmedicine.io") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [musicforlife.io") === false).filter((item) => item.toLowerCase().includes("if the truvvl embed is unsupported by your current frontend, click this link to view this story") === false).filter((item) => item.toLowerCase().includes("<center><em>posted from truvvl") === false).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.io/') === false).filter((item) => item.toLowerCase().includes("read this post on travelfeed.io for the best experience") === false).filter((item) => item.toLowerCase().includes('posted via <a href="https://www.dporn.co/"') === false).filter((item) => item.toLowerCase().includes("\u25B6\uFE0F [watch on 3speak](https://3speak") === false).filter((item) => item.toLowerCase().includes("<sup><sub>posted via [inji.com]") === false).filter((item) => item.toLowerCase().includes("view this post on [liketu]") === false).filter((item) => item.toLowerCase().includes("[via Inbox]") === false).filter((item) => item.toLowerCase().includes("<sub>[via apps from](") === false).join("\n") : "").replace('Posted via <a href="https://d.buzz" data-link="promote-link">D.Buzz</a>', "").replace('<div class="pull-right"><a href="/@hive.engage"></a></div>', "").replace('<div><a href="https://engage.hivechain.app"></a></div>', "").replace(`<div class="text-center"><img src="https://cdn.steemitimages.com/DQmNp6YwAm2qwquALZw8PdcovDorwaBSFuxQ38TrYziGT6b/A-20.png"><a href="https://bit.ly/actifit-app"><img src="https://cdn.steemitimages.com/DQmQqfpSmcQtfrHAtzfBtVccXwUL9vKNgZJ2j93m8WNjizw/l5.png"></a><a href="https://bit.ly/actifit-ios"><img src="https://cdn.steemitimages.com/DQmbWy8KzKT1UvCvznUTaFPw6wBUcyLtBT5XL9wdbB7Hfmn/l6.png"></a></div>`, "");
|
|
1694
|
+
return (s ? s.split("\n").filter((item) => item.toLowerCase().includes("posted using [partiko") === false).filter((item) => item.toLowerCase().includes("posted using [dapplr") === false).filter((item) => item.toLowerCase().includes("posted using [leofinance") === false).filter((item) => item.toLowerCase().includes("posted via [neoxian") === false).filter((item) => item.toLowerCase().includes("posted using [neoxian") === false).filter((item) => item.toLowerCase().includes("posted via [first context") === false).filter((item) => item.toLowerCase().includes("posted with [stemgeeks") === false).filter((item) => item.toLowerCase().includes("posted using [bilpcoin") === false).filter((item) => item.toLowerCase().includes("posted using [inleo") === false).filter((item) => item.toLowerCase().includes("posted using [sportstalksocial]") === false).filter((item) => item.toLowerCase().includes("<center><sub>[posted using aeneas.blog") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [proofofbrain.io") === false).filter((item) => item.toLowerCase().includes("<center>posted on [hypnochain") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [weedcash.network") === false).filter((item) => item.toLowerCase().includes("<center>posted on [naturalmedicine.io") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [musicforlife.io") === false).filter((item) => item.toLowerCase().includes("if the truvvl embed is unsupported by your current frontend, click this link to view this story") === false).filter((item) => item.toLowerCase().includes("<center><em>posted from truvvl") === false).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.io/') === false).filter((item) => item.toLowerCase().includes("read this post on travelfeed.io for the best experience") === false).filter((item) => item.toLowerCase().includes('posted via <a href="https://www.dporn.co/"') === false).filter((item) => item.toLowerCase().includes("\u25B6\uFE0F [watch on 3speak](https://3speak") === false).filter((item) => item.toLowerCase().includes("<sup><sub>posted via [inji.com]") === false).filter((item) => item.toLowerCase().includes("view this post on [liketu]") === false).filter((item) => item.toLowerCase().includes("[via Inbox]") === false).filter((item) => item.toLowerCase().includes("<sub>[via apps from](") === false).join("\n") : "").replace('Posted via <a href="https://d.buzz" data-link="promote-link">D.Buzz</a>', "").replace('<div class="pull-right"><a href="/@hive.engage"></a></div>', "").replace('<div><a href="https://engage.hivechain.app"></a></div>', "").replace(`<div class="text-center"><img src="https://cdn.steemitimages.com/DQmNp6YwAm2qwquALZw8PdcovDorwaBSFuxQ38TrYziGT6b/A-20.png"><a href="https://bit.ly/actifit-app"><img src="https://cdn.steemitimages.com/DQmQqfpSmcQtfrHAtzfBtVccXwUL9vKNgZJ2j93m8WNjizw/l5.png"></a><a href="https://bit.ly/actifit-ios"><img src="https://cdn.steemitimages.com/DQmbWy8KzKT1UvCvznUTaFPw6wBUcyLtBT5XL9wdbB7Hfmn/l6.png"></a></div>`, "");
|
|
1689
1695
|
}
|
|
1690
1696
|
var domSerializer = domSerializerModule__namespace.default || domSerializerModule__namespace;
|
|
1691
1697
|
var lolightPromise = null;
|