@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.
@@ -222,7 +222,7 @@ function toSerializableResponse(body, response) {
222
222
  function fromSerializableResponse([body, init]) {
223
223
  return [body, new Response(body, init)];
224
224
  }
225
- var checkGraphQLErrors = (body) => !body?.errors;
225
+ var checkGraphQLErrors = (body, response) => !body?.errors && response.status < 400;
226
226
  var swrLock = /* @__PURE__ */ new Set();
227
227
  async function runWithCache(cacheKey, actionFn, {
228
228
  strategy = CacheShort(),
@@ -357,7 +357,7 @@ var warnOnce = (string) => {
357
357
  };
358
358
 
359
359
  // src/version.ts
360
- var LIB_VERSION = "2023.7.13";
360
+ var LIB_VERSION = "2023.7.15";
361
361
 
362
362
  // src/storefront.ts
363
363
  var StorefrontApiError = class extends Error {
@@ -864,6 +864,19 @@ var graphiqlLoader = async function graphiqlLoader2({
864
864
  );
865
865
  };
866
866
 
867
+ // src/seo/escape.ts
868
+ var ESCAPE_LOOKUP = {
869
+ "&": "\\u0026",
870
+ ">": "\\u003e",
871
+ "<": "\\u003c",
872
+ "\u2028": "\\u2028",
873
+ "\u2029": "\\u2029"
874
+ };
875
+ var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
876
+ function escapeHtml(html) {
877
+ return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
878
+ }
879
+
867
880
  // src/seo/generate-seo-tags.ts
868
881
  var ERROR_PREFIX = "Error in SEO input: ";
869
882
  var schema = {
@@ -1037,7 +1050,9 @@ function generateSeoTags(seoInput) {
1037
1050
  "script",
1038
1051
  {
1039
1052
  type: "application/ld+json",
1040
- children: JSON.stringify(block)
1053
+ children: JSON.stringify(block, (k, value) => {
1054
+ return typeof value === "string" ? escapeHtml(value) : value;
1055
+ })
1041
1056
  },
1042
1057
  // @ts-expect-error
1043
1058
  `json-ld-${block?.["@type"] || block?.name || index++}`