@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.mjs
CHANGED
|
@@ -714,6 +714,9 @@ function buildSrcSetForFormat(url, format = "match") {
|
|
|
714
714
|
var STATIC_RASTER_PATH_EXT = /\.(?:jpe?g|png|webp)$/i;
|
|
715
715
|
var SIZED_PROXY_PATH = /^\/\d+x\d+\//;
|
|
716
716
|
function isPictureEligibleRawUrl(rawUrl) {
|
|
717
|
+
return isPictureEligible(rawUrl, true);
|
|
718
|
+
}
|
|
719
|
+
function isPictureEligible(rawUrl, mayUnwrapLegacy) {
|
|
717
720
|
if (!rawUrl || typeof rawUrl !== "string") return false;
|
|
718
721
|
let u;
|
|
719
722
|
try {
|
|
@@ -722,7 +725,10 @@ function isPictureEligibleRawUrl(rawUrl) {
|
|
|
722
725
|
return false;
|
|
723
726
|
}
|
|
724
727
|
if (u.protocol !== "http:" && u.protocol !== "https:") return false;
|
|
725
|
-
if (isLegacySizedProxyUrl(rawUrl))
|
|
728
|
+
if (mayUnwrapLegacy && isLegacySizedProxyUrl(rawUrl)) {
|
|
729
|
+
const nested = extractLegacySizedSource(rawUrl);
|
|
730
|
+
return nested !== null && isPictureEligible(nested, false);
|
|
731
|
+
}
|
|
726
732
|
const host = `${u.protocol}//${u.host}`;
|
|
727
733
|
const isProxyHost = host === proxyBase || host === "https://images.ecency.com";
|
|
728
734
|
if (isProxyHost && (u.pathname.startsWith("/p/") || u.pathname.startsWith("/u/") || SIZED_PROXY_PATH.test(u.pathname))) {
|
|
@@ -10255,10 +10261,6 @@ function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency
|
|
|
10255
10261
|
}
|
|
10256
10262
|
|
|
10257
10263
|
// src/catch-post-image.ts
|
|
10258
|
-
var gifLinkRegex = /\.(gif)$/i;
|
|
10259
|
-
function isGifLink(link) {
|
|
10260
|
-
return gifLinkRegex.test(link);
|
|
10261
|
-
}
|
|
10262
10264
|
var BACKTICK_FENCE_RE = /```[\s\S]*?```/g;
|
|
10263
10265
|
var TILDE_FENCE_RE = /~~~[\s\S]*?~~~/g;
|
|
10264
10266
|
var INLINE_CODE_RE = /`[^`\n]*`/g;
|
|
@@ -10763,11 +10765,7 @@ function firstMetaUrl(value) {
|
|
|
10763
10765
|
return void 0;
|
|
10764
10766
|
}
|
|
10765
10767
|
function proxifyFound(src, width, height, format) {
|
|
10766
|
-
|
|
10767
|
-
if (isGifLink(decoded)) {
|
|
10768
|
-
return proxifyImageSrc(decoded, 0, 0, format);
|
|
10769
|
-
}
|
|
10770
|
-
return proxifyImageSrc(decoded, width, height, format);
|
|
10768
|
+
return proxifyImageSrc(decodeEntities(src), width, height, format);
|
|
10771
10769
|
}
|
|
10772
10770
|
function getImage(entry, width = 0, height = 0, format = "match", fastMode = false) {
|
|
10773
10771
|
let meta;
|
|
@@ -10782,29 +10780,17 @@ function getImage(entry, width = 0, height = 0, format = "match", fastMode = fal
|
|
|
10782
10780
|
}
|
|
10783
10781
|
const thumbnail = firstMetaUrl(meta?.thumbnails);
|
|
10784
10782
|
if (thumbnail) {
|
|
10785
|
-
const
|
|
10786
|
-
const proxied = isGifLink(decodedThumbnail) ? proxifyImageSrc(decodedThumbnail, 0, 0, format) : proxifyImageSrc(decodedThumbnail, width, height, format);
|
|
10783
|
+
const proxied = proxifyImageSrc(decodeEntities(thumbnail), width, height, format);
|
|
10787
10784
|
if (proxied) {
|
|
10788
10785
|
return proxied;
|
|
10789
10786
|
}
|
|
10790
10787
|
}
|
|
10791
10788
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
10792
|
-
|
|
10793
|
-
if (isGifLink(decodedImage)) {
|
|
10794
|
-
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
10795
|
-
}
|
|
10796
|
-
return proxifyImageSrc(decodedImage, width, height, format);
|
|
10789
|
+
return proxifyImageSrc(decodeEntities(meta.image), width, height, format);
|
|
10797
10790
|
}
|
|
10798
10791
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
10799
10792
|
if (typeof meta.image[0] === "string") {
|
|
10800
|
-
|
|
10801
|
-
if (isGifLink(decodedImage)) {
|
|
10802
|
-
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
10803
|
-
}
|
|
10804
|
-
return proxifyImageSrc(decodedImage, width, height, format);
|
|
10805
|
-
}
|
|
10806
|
-
if (isGifLink(meta.image[0])) {
|
|
10807
|
-
return proxifyImageSrc(meta.image[0], 0, 0, format);
|
|
10793
|
+
return proxifyImageSrc(decodeEntities(meta.image[0]), width, height, format);
|
|
10808
10794
|
}
|
|
10809
10795
|
return proxifyImageSrc(meta.image[0], width, height, format);
|
|
10810
10796
|
}
|