@ecency/render-helper 2.5.35 → 2.5.37
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 +4 -4
- package/dist/browser/index.js +11 -25
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +11 -25
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +11 -25
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -741,6 +741,9 @@ function buildSrcSetForFormat(url, format = "match") {
|
|
|
741
741
|
var STATIC_RASTER_PATH_EXT = /\.(?:jpe?g|png|webp)$/i;
|
|
742
742
|
var SIZED_PROXY_PATH = /^\/\d+x\d+\//;
|
|
743
743
|
function isPictureEligibleRawUrl(rawUrl) {
|
|
744
|
+
return isPictureEligible(rawUrl, true);
|
|
745
|
+
}
|
|
746
|
+
function isPictureEligible(rawUrl, mayUnwrapLegacy) {
|
|
744
747
|
if (!rawUrl || typeof rawUrl !== "string") return false;
|
|
745
748
|
let u;
|
|
746
749
|
try {
|
|
@@ -749,7 +752,10 @@ function isPictureEligibleRawUrl(rawUrl) {
|
|
|
749
752
|
return false;
|
|
750
753
|
}
|
|
751
754
|
if (u.protocol !== "http:" && u.protocol !== "https:") return false;
|
|
752
|
-
if (isLegacySizedProxyUrl(rawUrl))
|
|
755
|
+
if (mayUnwrapLegacy && isLegacySizedProxyUrl(rawUrl)) {
|
|
756
|
+
const nested = extractLegacySizedSource(rawUrl);
|
|
757
|
+
return nested !== null && isPictureEligible(nested, false);
|
|
758
|
+
}
|
|
753
759
|
const host = `${u.protocol}//${u.host}`;
|
|
754
760
|
const isProxyHost = host === proxyBase || host === "https://images.ecency.com";
|
|
755
761
|
if (isProxyHost && (u.pathname.startsWith("/p/") || u.pathname.startsWith("/u/") || SIZED_PROXY_PATH.test(u.pathname))) {
|
|
@@ -10282,10 +10288,6 @@ function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency
|
|
|
10282
10288
|
}
|
|
10283
10289
|
|
|
10284
10290
|
// src/catch-post-image.ts
|
|
10285
|
-
var gifLinkRegex = /\.(gif)$/i;
|
|
10286
|
-
function isGifLink(link) {
|
|
10287
|
-
return gifLinkRegex.test(link);
|
|
10288
|
-
}
|
|
10289
10291
|
var BACKTICK_FENCE_RE = /```[\s\S]*?```/g;
|
|
10290
10292
|
var TILDE_FENCE_RE = /~~~[\s\S]*?~~~/g;
|
|
10291
10293
|
var INLINE_CODE_RE = /`[^`\n]*`/g;
|
|
@@ -10790,11 +10792,7 @@ function firstMetaUrl(value) {
|
|
|
10790
10792
|
return void 0;
|
|
10791
10793
|
}
|
|
10792
10794
|
function proxifyFound(src, width, height, format) {
|
|
10793
|
-
|
|
10794
|
-
if (isGifLink(decoded)) {
|
|
10795
|
-
return proxifyImageSrc(decoded, 0, 0, format);
|
|
10796
|
-
}
|
|
10797
|
-
return proxifyImageSrc(decoded, width, height, format);
|
|
10795
|
+
return proxifyImageSrc(decodeEntities(src), width, height, format);
|
|
10798
10796
|
}
|
|
10799
10797
|
function getImage(entry, width = 0, height = 0, format = "match", fastMode = false) {
|
|
10800
10798
|
let meta;
|
|
@@ -10809,29 +10807,17 @@ function getImage(entry, width = 0, height = 0, format = "match", fastMode = fal
|
|
|
10809
10807
|
}
|
|
10810
10808
|
const thumbnail = firstMetaUrl(meta?.thumbnails);
|
|
10811
10809
|
if (thumbnail) {
|
|
10812
|
-
const
|
|
10813
|
-
const proxied = isGifLink(decodedThumbnail) ? proxifyImageSrc(decodedThumbnail, 0, 0, format) : proxifyImageSrc(decodedThumbnail, width, height, format);
|
|
10810
|
+
const proxied = proxifyImageSrc(decodeEntities(thumbnail), width, height, format);
|
|
10814
10811
|
if (proxied) {
|
|
10815
10812
|
return proxied;
|
|
10816
10813
|
}
|
|
10817
10814
|
}
|
|
10818
10815
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
10819
|
-
|
|
10820
|
-
if (isGifLink(decodedImage)) {
|
|
10821
|
-
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
10822
|
-
}
|
|
10823
|
-
return proxifyImageSrc(decodedImage, width, height, format);
|
|
10816
|
+
return proxifyImageSrc(decodeEntities(meta.image), width, height, format);
|
|
10824
10817
|
}
|
|
10825
10818
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
10826
10819
|
if (typeof meta.image[0] === "string") {
|
|
10827
|
-
|
|
10828
|
-
if (isGifLink(decodedImage)) {
|
|
10829
|
-
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
10830
|
-
}
|
|
10831
|
-
return proxifyImageSrc(decodedImage, width, height, format);
|
|
10832
|
-
}
|
|
10833
|
-
if (isGifLink(meta.image[0])) {
|
|
10834
|
-
return proxifyImageSrc(meta.image[0], 0, 0, format);
|
|
10820
|
+
return proxifyImageSrc(decodeEntities(meta.image[0]), width, height, format);
|
|
10835
10821
|
}
|
|
10836
10822
|
return proxifyImageSrc(meta.image[0], width, height, format);
|
|
10837
10823
|
}
|