@faststore/api 1.12.6 → 1.12.8

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/api.esm.js CHANGED
@@ -1687,6 +1687,18 @@ const Query = {
1687
1687
  }
1688
1688
 
1689
1689
  const sku = await skuLoader.load(skuId);
1690
+ /**
1691
+ * Here be dragons 🦄🦄🦄
1692
+ *
1693
+ * In some cases, the slug has a valid skuId for a different
1694
+ * product. This condition makes sure that the fetched sku
1695
+ * is the one we actually asked for
1696
+ * */
1697
+
1698
+ if (slug && sku.isVariantOf.linkText && !slug.startsWith(sku.isVariantOf.linkText)) {
1699
+ throw new Error(`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${slug}, linkText: ${sku.isVariantOf.linkText}`);
1700
+ }
1701
+
1690
1702
  return sku;
1691
1703
  } catch (err) {
1692
1704
  if (slug == null) {
@@ -1913,10 +1925,12 @@ const StoreSearchResult = {
1913
1925
  // a full text search.
1914
1926
 
1915
1927
  if (searchArgs.query) {
1928
+ var _products$correction$, _products$correction;
1929
+
1916
1930
  sp.sendEvent({
1917
1931
  type: 'search.query',
1918
1932
  text: searchArgs.query,
1919
- misspelled: products.correction.misspelled,
1933
+ misspelled: (_products$correction$ = (_products$correction = products.correction) == null ? void 0 : _products$correction.misspelled) != null ? _products$correction$ : false,
1920
1934
  match: products.recordsFiltered,
1921
1935
  operator: products.operator
1922
1936
  }).catch(console.error);