@getlupa/vue 0.7.0 → 0.7.2

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.
@@ -1745,12 +1745,12 @@ const escapeHtml = (value) => {
1745
1745
  });
1746
1746
  return output;
1747
1747
  };
1748
- const inputMatches = (input, possibleValues) => {
1748
+ const inputsAreEqual = (input, possibleValues) => {
1749
1749
  if (!input) {
1750
1750
  return false;
1751
1751
  }
1752
1752
  const normalizedInput = getNormalizedString(input);
1753
- return possibleValues.some((v) => getNormalizedString(v).startsWith(normalizedInput));
1753
+ return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
1754
1754
  };
1755
1755
  const initAnalyticsTracking = (analyticsOptions) => {
1756
1756
  try {
@@ -2757,11 +2757,14 @@ const useRedirectionStore = defineStore("redirections", () => {
2757
2757
  if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
2758
2758
  return false;
2759
2759
  }
2760
- const redirectTo = redirections.value.rules.find((r) => inputMatches(input, r.sources));
2760
+ const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
2761
2761
  if (!redirectTo) {
2762
2762
  return false;
2763
2763
  }
2764
- const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransfromer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransfromer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
2764
+ const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
2765
+ if (url === void 0 || url === null || url === "") {
2766
+ return false;
2767
+ }
2765
2768
  if (routingBehavior === "event") {
2766
2769
  emitRoutingEvent(url);
2767
2770
  } else {
@@ -1743,12 +1743,12 @@ const escapeHtml = (value) => {
1743
1743
  });
1744
1744
  return output;
1745
1745
  };
1746
- const inputMatches = (input, possibleValues) => {
1746
+ const inputsAreEqual = (input, possibleValues) => {
1747
1747
  if (!input) {
1748
1748
  return false;
1749
1749
  }
1750
1750
  const normalizedInput = getNormalizedString(input);
1751
- return possibleValues.some((v) => getNormalizedString(v).startsWith(normalizedInput));
1751
+ return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
1752
1752
  };
1753
1753
  const initAnalyticsTracking = (analyticsOptions) => {
1754
1754
  try {
@@ -2755,11 +2755,14 @@ const useRedirectionStore = defineStore("redirections", () => {
2755
2755
  if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
2756
2756
  return false;
2757
2757
  }
2758
- const redirectTo = redirections.value.rules.find((r) => inputMatches(input, r.sources));
2758
+ const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
2759
2759
  if (!redirectTo) {
2760
2760
  return false;
2761
2761
  }
2762
- const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransfromer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransfromer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
2762
+ const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
2763
+ if (url === void 0 || url === null || url === "") {
2764
+ return false;
2765
+ }
2763
2766
  if (routingBehavior === "event") {
2764
2767
  emitRoutingEvent(url);
2765
2768
  } else {
@@ -22,10 +22,11 @@ import ChatContainer from './components/chat/ChatContainer.vue';
22
22
  import { getInitialSearchResults } from './utils/ssr.utils';
23
23
  import { ChatOptions, ChatSettings } from './types/chat/ChatOptions';
24
24
  import { QueryParams } from './types/search-results/QueryParams';
25
+ import { RedirectionOptions } from './types/redirections/RedirectionOptions';
25
26
  declare const initPinia: () => Pinia;
26
27
  declare const setupTracking: (options: TrackingOptions) => void;
27
28
  declare const LupaSearch: {
28
29
  install: (app: any) => void;
29
30
  };
30
31
  export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults };
31
- export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext };
32
+ export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext, RedirectionOptions };
@@ -2,5 +2,5 @@ export type RedirectionOptions = {
2
2
  enabled: boolean;
3
3
  queryKey: string;
4
4
  cacheSeconds?: number;
5
- urlTransfromer?: (redirectTo: string) => string;
5
+ urlTransformer?: (redirectTo: string) => string;
6
6
  };
@@ -8,3 +8,4 @@ export declare const getProductKey: (index: string, product: Document, idKey: st
8
8
  export declare const normalizeFloat: (value?: string) => number;
9
9
  export declare const escapeHtml: (value?: string) => string;
10
10
  export declare const inputMatches: (input: string, possibleValues: string[]) => boolean;
11
+ export declare const inputsAreEqual: (input: string, possibleValues: string[]) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",