@shopify/hydrogen 2023.7.13 → 2023.7.15

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.
@@ -316,7 +316,7 @@ function toSerializableResponse(body, response) {
316
316
  function fromSerializableResponse([body, init]) {
317
317
  return [body, new Response(body, init)];
318
318
  }
319
- var checkGraphQLErrors = (body) => !body?.errors;
319
+ var checkGraphQLErrors = (body, response) => !body?.errors && response.status < 400;
320
320
  var swrLock = /* @__PURE__ */ new Set();
321
321
  async function runWithCache(cacheKey, actionFn, {
322
322
  strategy = CacheShort(),
@@ -451,7 +451,7 @@ var warnOnce = (string) => {
451
451
  };
452
452
 
453
453
  // src/version.ts
454
- var LIB_VERSION = "2023.7.13";
454
+ var LIB_VERSION = "2023.7.15";
455
455
 
456
456
  // src/storefront.ts
457
457
  var StorefrontApiError = class extends Error {
@@ -958,6 +958,19 @@ var graphiqlLoader = async function graphiqlLoader2({
958
958
  );
959
959
  };
960
960
 
961
+ // src/seo/escape.ts
962
+ var ESCAPE_LOOKUP = {
963
+ "&": "\\u0026",
964
+ ">": "\\u003e",
965
+ "<": "\\u003c",
966
+ "\u2028": "\\u2028",
967
+ "\u2029": "\\u2029"
968
+ };
969
+ var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
970
+ function escapeHtml(html) {
971
+ return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
972
+ }
973
+
961
974
  // src/seo/generate-seo-tags.ts
962
975
  var ERROR_PREFIX = "Error in SEO input: ";
963
976
  var schema = {
@@ -1131,7 +1144,9 @@ function generateSeoTags(seoInput) {
1131
1144
  "script",
1132
1145
  {
1133
1146
  type: "application/ld+json",
1134
- children: JSON.stringify(block)
1147
+ children: JSON.stringify(block, (k, value) => {
1148
+ return typeof value === "string" ? escapeHtml(value) : value;
1149
+ })
1135
1150
  },
1136
1151
  // @ts-expect-error
1137
1152
  `json-ld-${block?.["@type"] || block?.name || index++}`