@ecency/render-helper 2.5.36 → 2.5.38

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.
@@ -156,10 +156,10 @@ declare function buildSrcSetForFormat(url?: string, format?: 'avif' | 'webp' | '
156
156
  * Whether a RAW (pre-proxify) image URL is safe to offer avif/webp `<source>`
157
157
  * renditions for. Requires an http(s) URL whose PATHNAME ends in a static-raster
158
158
  * extension and that is NOT already proxified — already-proxified routes (`/p/`
159
- * base58 hash, `/u/` avatars, `WxH` sized) have the original extension stripped,
160
- * so we can't prove the underlying bytes aren't an animated gif and must fall
161
- * back to a bare img. URL parsing (not string regex on the host) keeps the host
162
- * comparison exact and avoids an interpolated-hostname regex.
159
+ * base58 hash, `/u/` avatars) have the original extension stripped, so we can't
160
+ * prove the underlying bytes aren't an animated gif and must fall back to a bare
161
+ * img. URL parsing (not string regex on the host) keeps the host comparison
162
+ * exact and avoids an interpolated-hostname regex.
163
163
  */
164
164
  declare function isPictureEligibleRawUrl(rawUrl?: string): boolean;
165
165
  /**
@@ -716,6 +716,9 @@ function buildSrcSetForFormat(url, format = "match") {
716
716
  var STATIC_RASTER_PATH_EXT = /\.(?:jpe?g|png|webp)$/i;
717
717
  var SIZED_PROXY_PATH = /^\/\d+x\d+\//;
718
718
  function isPictureEligibleRawUrl(rawUrl) {
719
+ return isPictureEligible(rawUrl, true);
720
+ }
721
+ function isPictureEligible(rawUrl, mayUnwrapLegacy) {
719
722
  if (!rawUrl || typeof rawUrl !== "string") return false;
720
723
  let u;
721
724
  try {
@@ -724,7 +727,10 @@ function isPictureEligibleRawUrl(rawUrl) {
724
727
  return false;
725
728
  }
726
729
  if (u.protocol !== "http:" && u.protocol !== "https:") return false;
727
- if (isLegacySizedProxyUrl(rawUrl)) return true;
730
+ if (mayUnwrapLegacy && isLegacySizedProxyUrl(rawUrl)) {
731
+ const nested = extractLegacySizedSource(rawUrl);
732
+ return nested !== null && isPictureEligible(nested, false);
733
+ }
728
734
  const host = `${u.protocol}//${u.host}`;
729
735
  const isProxyHost = host === proxyBase || host === "https://images.ecency.com";
730
736
  if (isProxyHost && (u.pathname.startsWith("/p/") || u.pathname.startsWith("/u/") || SIZED_PROXY_PATH.test(u.pathname))) {