@decocms/blocks 7.71.3 → 7.71.5
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/package.json +1 -1
- package/src/cms/resolve.test.ts +114 -13
- package/src/cms/resolve.ts +58 -20
- package/src/cms/schema.ts +5 -1
- package/src/hooks/Image.test.ts +54 -0
- package/src/hooks/Image.tsx +12 -4
package/package.json
CHANGED
package/src/cms/resolve.test.ts
CHANGED
|
@@ -842,8 +842,15 @@ describe("extractSeoFromProps — commerce jsonLD structured data", () => {
|
|
|
842
842
|
// Highest-position breadcrumb item wins.
|
|
843
843
|
expect(seo.canonical).toBe("https://x.com/a/b");
|
|
844
844
|
expect(seo.noIndexing).toBe(false);
|
|
845
|
-
expect(seo.jsonLDs).toHaveLength(
|
|
846
|
-
expect(seo.jsonLDs?.[0]).toMatchObject({
|
|
845
|
+
expect(seo.jsonLDs).toHaveLength(2);
|
|
846
|
+
expect(seo.jsonLDs?.[0]).toMatchObject({
|
|
847
|
+
"@context": "https://schema.org",
|
|
848
|
+
"@type": "ItemList",
|
|
849
|
+
});
|
|
850
|
+
expect(seo.jsonLDs?.[1]).toMatchObject({
|
|
851
|
+
"@context": "https://schema.org",
|
|
852
|
+
"@type": "BreadcrumbList",
|
|
853
|
+
});
|
|
847
854
|
});
|
|
848
855
|
|
|
849
856
|
it("emits the product image and JSON-LD for a PDP", () => {
|
|
@@ -873,7 +880,7 @@ describe("extractSeoFromProps — commerce jsonLD structured data", () => {
|
|
|
873
880
|
});
|
|
874
881
|
expect(seo.title).toBe("Manual Title");
|
|
875
882
|
expect(seo.canonical).toBe("https://x.com/manual");
|
|
876
|
-
expect(seo.jsonLDs).toHaveLength(
|
|
883
|
+
expect(seo.jsonLDs).toHaveLength(2);
|
|
877
884
|
});
|
|
878
885
|
|
|
879
886
|
it("omits structured data for humans when ignoreStructuredData is set", () => {
|
|
@@ -893,7 +900,7 @@ describe("extractSeoFromProps — commerce jsonLD structured data", () => {
|
|
|
893
900
|
{ jsonLD: plp(), configJsonLD: { ignoreStructuredData: true } },
|
|
894
901
|
{ isEager: true },
|
|
895
902
|
);
|
|
896
|
-
expect(seo.jsonLDs).toHaveLength(
|
|
903
|
+
expect(seo.jsonLDs).toHaveLength(2);
|
|
897
904
|
expect(seo.title).toBe("PLP Title");
|
|
898
905
|
});
|
|
899
906
|
|
|
@@ -927,18 +934,110 @@ describe("extractSeoFromProps — commerce jsonLD structured data", () => {
|
|
|
927
934
|
expect(seo.jsonLDs).toBe(existing);
|
|
928
935
|
});
|
|
929
936
|
|
|
930
|
-
it("
|
|
931
|
-
const
|
|
932
|
-
|
|
937
|
+
it("emits a compact ItemList (position/url/name), not the whole listing page", () => {
|
|
938
|
+
const heavy = {
|
|
939
|
+
"@type": "Product",
|
|
940
|
+
name: "SKU name",
|
|
941
|
+
url: "https://x.com/p1/p",
|
|
942
|
+
isVariantOf: { name: "Product 1", hasVariant: [{ sku: "1" }, { sku: "2" }] },
|
|
943
|
+
additionalProperty: [{ name: "cluster", value: "42" }],
|
|
944
|
+
image: [{ url: "https://x.com/1.jpg" }],
|
|
945
|
+
video: [{ "@type": "VideoObject" }],
|
|
946
|
+
};
|
|
947
|
+
const seo = extractSeoFromProps({
|
|
948
|
+
jsonLD: plp({
|
|
949
|
+
products: [heavy, { "@type": "Product", name: "P2", url: "https://x.com/p2/p" }],
|
|
950
|
+
}),
|
|
951
|
+
});
|
|
952
|
+
expect(seo.jsonLDs?.[0]).toEqual({
|
|
953
|
+
"@context": "https://schema.org",
|
|
954
|
+
"@type": "ItemList",
|
|
955
|
+
numberOfItems: 2,
|
|
956
|
+
itemListElement: [
|
|
957
|
+
{ "@type": "ListItem", position: 1, url: "https://x.com/p1/p", name: "Product 1" },
|
|
958
|
+
{ "@type": "ListItem", position: 2, url: "https://x.com/p2/p", name: "P2" },
|
|
959
|
+
],
|
|
960
|
+
});
|
|
961
|
+
const json = JSON.stringify(seo.jsonLDs);
|
|
962
|
+
expect(json).not.toContain("hasVariant");
|
|
963
|
+
expect(json).not.toContain("additionalProperty");
|
|
964
|
+
expect(json).not.toContain("VideoObject");
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
it("points ListItems at the canonical product URL and drops items without one", () => {
|
|
968
|
+
const seo = extractSeoFromProps({
|
|
969
|
+
jsonLD: plp({
|
|
970
|
+
products: [
|
|
971
|
+
{
|
|
972
|
+
name: "SKU A",
|
|
973
|
+
url: "https://x.com/a/p?skuId=1",
|
|
974
|
+
isVariantOf: { name: "A", url: "https://x.com/a/p" },
|
|
975
|
+
},
|
|
976
|
+
{ name: "No URL" },
|
|
977
|
+
{ name: "B", url: "https://x.com/b/p?skuId=2" },
|
|
978
|
+
],
|
|
979
|
+
}),
|
|
980
|
+
});
|
|
981
|
+
expect(seo.jsonLDs?.[0].itemListElement).toEqual([
|
|
982
|
+
{ "@type": "ListItem", position: 1, url: "https://x.com/a/p", name: "A" },
|
|
983
|
+
{ "@type": "ListItem", position: 2, url: "https://x.com/b/p?skuId=2", name: "B" },
|
|
984
|
+
]);
|
|
985
|
+
expect(seo.jsonLDs?.[0].numberOfItems).toBe(2);
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
it("makes path-only breadcrumb items absolute without touching the source", () => {
|
|
989
|
+
const breadcrumb = {
|
|
990
|
+
"@type": "BreadcrumbList",
|
|
991
|
+
itemListElement: [
|
|
992
|
+
{ "@type": "ListItem", position: 1, name: "Cat", item: "/cat" },
|
|
993
|
+
{ "@type": "ListItem", position: 2, name: "Sub", item: "https://y.com/cat/sub" },
|
|
994
|
+
],
|
|
995
|
+
};
|
|
996
|
+
const seo = extractSeoFromProps({
|
|
997
|
+
jsonLD: plp({ breadcrumb, products: [{ name: "A", url: "https://x.com/a/p" }] }),
|
|
933
998
|
});
|
|
999
|
+
expect(seo.jsonLDs?.[1].itemListElement.map((el: { item: string }) => el.item)).toEqual([
|
|
1000
|
+
"https://x.com/cat",
|
|
1001
|
+
"https://y.com/cat/sub",
|
|
1002
|
+
]);
|
|
1003
|
+
// In-app breadcrumb (section data) keeps its relative links.
|
|
1004
|
+
expect(breadcrumb.itemListElement[0].item).toBe("/cat");
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
it("falls back to seo.canonical for the origin and leaves //host items alone", () => {
|
|
934
1008
|
const seo = extractSeoFromProps({
|
|
935
|
-
jsonLD:
|
|
936
|
-
|
|
1009
|
+
jsonLD: plp({
|
|
1010
|
+
seo: { title: "T", canonical: "https://z.com/cat" },
|
|
1011
|
+
products: [{ name: "No URL" }, { name: "A", url: "/a/p" }],
|
|
1012
|
+
breadcrumb: {
|
|
1013
|
+
"@type": "BreadcrumbList",
|
|
1014
|
+
itemListElement: [
|
|
1015
|
+
{ "@type": "ListItem", position: 1, name: "Cat", item: "/cat" },
|
|
1016
|
+
{ "@type": "ListItem", position: 2, name: "Ext", item: "//evil.com/x" },
|
|
1017
|
+
],
|
|
1018
|
+
},
|
|
1019
|
+
}),
|
|
937
1020
|
});
|
|
938
|
-
expect(seo.jsonLDs?.[
|
|
939
|
-
|
|
1021
|
+
expect(seo.jsonLDs?.[1].itemListElement.map((el: { item: string }) => el.item)).toEqual([
|
|
1022
|
+
"https://z.com/cat",
|
|
1023
|
+
"//evil.com/x",
|
|
1024
|
+
]);
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
it("omits the BreadcrumbList when the listing has no breadcrumb", () => {
|
|
1028
|
+
const seo = extractSeoFromProps({ jsonLD: plp({ breadcrumb: undefined }) });
|
|
1029
|
+
expect(seo.jsonLDs).toHaveLength(1);
|
|
1030
|
+
expect(seo.jsonLDs?.[0]).toMatchObject({ "@type": "ItemList" });
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
it("omitVariants empties PDP variants without mutating the source", () => {
|
|
1034
|
+
const source = pdp({
|
|
1035
|
+
product: { "@type": "Product", name: "P1", isVariantOf: { hasVariant: [{ sku: "1" }] } },
|
|
1036
|
+
});
|
|
1037
|
+
const seo = extractSeoFromProps({ jsonLD: source, omitVariants: true });
|
|
1038
|
+
expect(seo.jsonLDs?.[0].product.isVariantOf.hasVariant).toEqual([]);
|
|
940
1039
|
// biome-ignore lint/suspicious/noExplicitAny: test fixture
|
|
941
|
-
expect((source.
|
|
1040
|
+
expect((source.product as any).isVariantOf.hasVariant).toHaveLength(1);
|
|
942
1041
|
});
|
|
943
1042
|
});
|
|
944
1043
|
|
|
@@ -1258,7 +1357,9 @@ describe("layoutCacheKey — the resolved-layout cache is segmented by device",
|
|
|
1258
1357
|
// navigation.
|
|
1259
1358
|
|
|
1260
1359
|
it("mobile, tablet and desktop are three distinct keys", () => {
|
|
1261
|
-
const keys = [MOBILE_UA, TABLET_UA, DESKTOP_UA].map((ua) =>
|
|
1360
|
+
const keys = [MOBILE_UA, TABLET_UA, DESKTOP_UA].map((ua) =>
|
|
1361
|
+
layoutCacheKey(KEY, { userAgent: ua }),
|
|
1362
|
+
);
|
|
1262
1363
|
expect(new Set(keys).size).toBe(3);
|
|
1263
1364
|
});
|
|
1264
1365
|
|
package/src/cms/resolve.ts
CHANGED
|
@@ -1981,28 +1981,71 @@ function canonicalFromBreadcrumb(breadcrumb: unknown): string | undefined {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
1983
1983
|
/**
|
|
1984
|
-
* Shallow-prune a
|
|
1984
|
+
* Shallow-prune a PDP `jsonLD` before emitting it as structured data.
|
|
1985
1985
|
* Clones only when a prune option is set (the common path emits as-is), so a
|
|
1986
1986
|
* jsonLD shared with a body section is never mutated out from under it.
|
|
1987
1987
|
*/
|
|
1988
1988
|
function pruneCommerceJsonLD(
|
|
1989
1989
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1990
1990
|
jsonLD: Record<string, any>,
|
|
1991
|
-
opts: {
|
|
1991
|
+
opts: { omitVariants: boolean },
|
|
1992
1992
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1993
1993
|
): Record<string, any> {
|
|
1994
|
-
if (!opts.
|
|
1994
|
+
if (!opts.omitVariants || !jsonLD.product?.isVariantOf?.hasVariant) return jsonLD;
|
|
1995
1995
|
const clone = structuredClone(jsonLD);
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1996
|
+
clone.product.isVariantOf.hasVariant = [];
|
|
1997
|
+
return clone;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* schema.org structured data for a listing page: an `ItemList` of
|
|
2002
|
+
* position/url/name (what search engines read on category pages) plus the
|
|
2003
|
+
* `BreadcrumbList`. Emitting the resolved ProductListingPage itself is not
|
|
2004
|
+
* schema.org (no such type, no `@context`) and inlines every product with
|
|
2005
|
+
* variants/specs/images — multiple MB per page, in the HTML *and* in the
|
|
2006
|
+
* serialized route data, which pushes Workers past their memory limit.
|
|
2007
|
+
*/
|
|
2008
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2009
|
+
function plpStructuredData(plp: Record<string, any>): Record<string, unknown>[] {
|
|
2010
|
+
// Canonical product URL first: `url` is the SKU URL (`/p?skuId=N`), which
|
|
2011
|
+
// canonicalises elsewhere. Items without a URL are dropped (Google requires
|
|
2012
|
+
// `url` on summary-page items) before numbering, so positions stay contiguous.
|
|
2013
|
+
const itemListElement = (plp.products as any[]) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2014
|
+
.map((p) => ({ url: p.isVariantOf?.url ?? p.url, name: p.isVariantOf?.name ?? p.name }))
|
|
2015
|
+
.filter((item) => item.url)
|
|
2016
|
+
.map((item, i) => ({ "@type": "ListItem", position: i + 1, ...item }));
|
|
2017
|
+
const out: Record<string, unknown>[] = [
|
|
2018
|
+
{
|
|
2019
|
+
"@context": "https://schema.org",
|
|
2020
|
+
"@type": "ItemList",
|
|
2021
|
+
numberOfItems: itemListElement.length,
|
|
2022
|
+
itemListElement,
|
|
2023
|
+
},
|
|
2024
|
+
];
|
|
2025
|
+
if (plp.breadcrumb?.itemListElement?.length) {
|
|
2026
|
+
// Loaders emit path-only breadcrumb items (`/a/b`) for in-app links; in
|
|
2027
|
+
// structured data make them absolute, using the products' origin.
|
|
2028
|
+
const origin = originOf(itemListElement[0]?.url) ?? originOf(plp.seo?.canonical);
|
|
2029
|
+
out.push({
|
|
2030
|
+
...plp.breadcrumb,
|
|
2031
|
+
"@context": "https://schema.org",
|
|
2032
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2033
|
+
itemListElement: plp.breadcrumb.itemListElement.map((el: any) =>
|
|
2034
|
+
origin && typeof el.item === "string" && /^\/(?!\/)/.test(el.item)
|
|
2035
|
+
? { ...el, item: new URL(el.item, origin).href }
|
|
2036
|
+
: el,
|
|
2037
|
+
),
|
|
2038
|
+
});
|
|
2001
2039
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2040
|
+
return out;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
function originOf(url: unknown): string | undefined {
|
|
2044
|
+
try {
|
|
2045
|
+
return typeof url === "string" ? new URL(url).origin : undefined;
|
|
2046
|
+
} catch {
|
|
2047
|
+
return undefined;
|
|
2004
2048
|
}
|
|
2005
|
-
return clone;
|
|
2006
2049
|
}
|
|
2007
2050
|
|
|
2008
2051
|
/**
|
|
@@ -2062,18 +2105,13 @@ function deriveCommerceSeoFromJsonLD(
|
|
|
2062
2105
|
// humans only; crawlers (and the `?__deco_ssr=1` audit override) still get it
|
|
2063
2106
|
// so indexing/rich results are unaffected. An empty page contributes no
|
|
2064
2107
|
// ItemList regardless.
|
|
2065
|
-
const configJsonLD = props.configJsonLD as
|
|
2066
|
-
| { ignoreStructuredData?: boolean; removeVideos?: boolean }
|
|
2067
|
-
| undefined;
|
|
2068
2108
|
const ignore = sectionIgnoresStructuredData(props);
|
|
2069
2109
|
if ((ignore && !isEager) || isEmpty) return;
|
|
2070
2110
|
|
|
2071
|
-
seo.jsonLDs =
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
omitVariants: props.omitVariants === true
|
|
2075
|
-
}),
|
|
2076
|
-
];
|
|
2111
|
+
seo.jsonLDs =
|
|
2112
|
+
type === "ProductListingPage"
|
|
2113
|
+
? plpStructuredData(jsonLD)
|
|
2114
|
+
: [pruneCommerceJsonLD(jsonLD, { omitVariants: props.omitVariants === true })];
|
|
2077
2115
|
}
|
|
2078
2116
|
|
|
2079
2117
|
/**
|
package/src/cms/schema.ts
CHANGED
|
@@ -882,7 +882,11 @@ function buildFrameworkSections(sectionAnyOf: any[], loaderUnion: any[]) {
|
|
|
882
882
|
type: "object",
|
|
883
883
|
title: "Structured Data",
|
|
884
884
|
properties: {
|
|
885
|
-
removeVideos: {
|
|
885
|
+
removeVideos: {
|
|
886
|
+
type: "boolean",
|
|
887
|
+
title: "Remove videos (deprecated)",
|
|
888
|
+
description: "No effect: listing structured data is an ItemList, which carries no videos.",
|
|
889
|
+
},
|
|
886
890
|
ignoreStructuredData: {
|
|
887
891
|
type: "boolean",
|
|
888
892
|
title: "Ignore Structured Data",
|
package/src/hooks/Image.test.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import {
|
|
3
|
+
getImageCdnDomain,
|
|
3
4
|
getImageQuality,
|
|
4
5
|
getOptimizedMediaUrl,
|
|
5
6
|
getSrcSet,
|
|
6
7
|
type ImageQuality,
|
|
8
|
+
registerImageCdnDomain,
|
|
7
9
|
registerImageQuality,
|
|
8
10
|
} from "./Image";
|
|
9
11
|
|
|
@@ -85,6 +87,50 @@ describe("getOptimizedMediaUrl", () => {
|
|
|
85
87
|
expect(result).toContain("fit=cover");
|
|
86
88
|
expect(result).toContain("src=https://cdn.example.com/foo.jpg");
|
|
87
89
|
});
|
|
90
|
+
|
|
91
|
+
it("strips the legacy decoims.com host so the CDN doesn't fetch itself (508)", () => {
|
|
92
|
+
const result = getOptimizedMediaUrl({
|
|
93
|
+
originalSrc: "https://decoims.com/site/2026/09/banner.png",
|
|
94
|
+
width: 100,
|
|
95
|
+
fit: "cover",
|
|
96
|
+
});
|
|
97
|
+
expect(result).toContain("&src=site/2026/09/banner.png");
|
|
98
|
+
expect(result).not.toContain("src=https://decoims.com/");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("strips decoims.com and drops its query string", () => {
|
|
102
|
+
const result = getOptimizedMediaUrl({
|
|
103
|
+
originalSrc: "https://decoims.com/site/a.png?v=2",
|
|
104
|
+
width: 100,
|
|
105
|
+
fit: "cover",
|
|
106
|
+
});
|
|
107
|
+
expect(result).toMatch(/&src=site\/a\.png$/);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("keeps decoims.com absolute on Azion CDNs, which may 404 the relative path", () => {
|
|
111
|
+
const prev = getImageCdnDomain();
|
|
112
|
+
registerImageCdnDomain("deco-assets.edgedeco.com");
|
|
113
|
+
try {
|
|
114
|
+
const result = getOptimizedMediaUrl({
|
|
115
|
+
originalSrc: "https://decoims.com/site/a.png",
|
|
116
|
+
width: 100,
|
|
117
|
+
fit: "cover",
|
|
118
|
+
});
|
|
119
|
+
expect(result).toContain("https://deco-assets.edgedeco.com/image?");
|
|
120
|
+
expect(result).toContain("&src=https://decoims.com/site/a.png");
|
|
121
|
+
} finally {
|
|
122
|
+
registerImageCdnDomain(prev);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("only strips a leading Deco host", () => {
|
|
127
|
+
const result = getOptimizedMediaUrl({
|
|
128
|
+
originalSrc: "https://cdn.example.com/https://decoims.com/x.png",
|
|
129
|
+
width: 100,
|
|
130
|
+
fit: "cover",
|
|
131
|
+
});
|
|
132
|
+
expect(result).toContain("&src=https://cdn.example.com/https://decoims.com/x.png");
|
|
133
|
+
});
|
|
88
134
|
});
|
|
89
135
|
|
|
90
136
|
describe("getSrcSet", () => {
|
|
@@ -183,3 +229,11 @@ describe("registerImageQuality", () => {
|
|
|
183
229
|
expect(getImageQuality()).toBeUndefined();
|
|
184
230
|
});
|
|
185
231
|
});
|
|
232
|
+
|
|
233
|
+
describe("getSrcSet — legacy decoims.com sources", () => {
|
|
234
|
+
it("strips decoims.com from every srcset entry", () => {
|
|
235
|
+
const result = getSrcSet("https://decoims.com/site/b.png", 200, 100, "cover") ?? "";
|
|
236
|
+
expect(result).not.toContain("src=https://decoims.com/");
|
|
237
|
+
for (const entry of result.split(", ")) expect(entry).toContain("&src=site/b.png");
|
|
238
|
+
});
|
|
239
|
+
});
|
package/src/hooks/Image.tsx
CHANGED
|
@@ -5,8 +5,15 @@ import { forwardRef } from "react";
|
|
|
5
5
|
// Known asset prefixes that get stripped to produce a relative src path
|
|
6
6
|
// -------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
// Anchored: only a leading host is stripped.
|
|
9
|
+
const DECO_ASSET_PREFIX_RE =
|
|
10
|
+
/^https:\/\/(?:assets\.decocache\.com|deco-sites-assets\.s3\.sa-east-1\.amazonaws\.com)\//;
|
|
11
|
+
// decoims.com — the legacy default image CDN (pre-#495). Decofiles are full of
|
|
12
|
+
// these URLs; passing one as `src=` to a Cloudflare Deco CDN makes it fetch
|
|
13
|
+
// itself → 508 Loop Detected. Azion CDNs (edgedeco/decoazn) fetch it fine but
|
|
14
|
+
// may 404 on the relative path, so only strip it for the Cloudflare ones.
|
|
15
|
+
const DECOIMS_PREFIX_RE = /^https:\/\/decoims\.com\//;
|
|
16
|
+
const CLOUDFLARE_CDNS = new Set(["assets.decocms.com", "decoims.com"]);
|
|
10
17
|
|
|
11
18
|
// -------------------------------------------------------------------------
|
|
12
19
|
// Configurable CDN domain
|
|
@@ -132,7 +139,7 @@ function optimizeShopify(originalSrc: string, width: number, height?: number): s
|
|
|
132
139
|
/**
|
|
133
140
|
* Builds an optimized image URL.
|
|
134
141
|
*
|
|
135
|
-
* For Deco-hosted images (decocache / S3), strips the known prefix and
|
|
142
|
+
* For Deco-hosted images (decocache / S3 / decoims), strips the known prefix and
|
|
136
143
|
* routes through the Deco image CDN for edge resize + format conversion.
|
|
137
144
|
*
|
|
138
145
|
* For platform-specific images (VTEX, Shopify), rewrites the URL using
|
|
@@ -169,7 +176,8 @@ export function getOptimizedMediaUrl(opts: OptimizationOptions): string {
|
|
|
169
176
|
return optimizeShopify(originalSrc, width, height);
|
|
170
177
|
}
|
|
171
178
|
|
|
172
|
-
let imageSource = originalSrc.replace(
|
|
179
|
+
let imageSource = originalSrc.replace(DECO_ASSET_PREFIX_RE, "").split("?")[0];
|
|
180
|
+
if (CLOUDFLARE_CDNS.has(imageCdnDomain)) imageSource = imageSource.replace(DECOIMS_PREFIX_RE, "");
|
|
173
181
|
|
|
174
182
|
// Already on the image CDN — strip the host so we don't proxy through ourselves.
|
|
175
183
|
const cdnPrefix = `https://${imageCdnDomain}/`;
|