@garagem-ai/site-sdk 0.13.4 → 0.13.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/dist/index.mjs CHANGED
@@ -546,6 +546,19 @@ var LISTING_TYPE_ALIASES = {
546
546
  rental: ["alugar"]
547
547
  };
548
548
 
549
+ // ../search-url/listing-identity.ts
550
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
551
+ var LISTING_CODE_RE = /^(?:[A-Za-z0-9]+|[A-Z0-9]+(?:-[A-Z0-9]+)+)$/;
552
+ var LETTER_CODE_RE = /^[A-Z]{5}$/;
553
+ function isShortListingIdentity(segment) {
554
+ if (UUID_RE.test(segment) || LETTER_CODE_RE.test(segment)) return true;
555
+ return /\d/.test(segment) && LISTING_CODE_RE.test(segment);
556
+ }
557
+ function isShortListingPath(pathname) {
558
+ const parts = (pathname.split(/[?#]/)[0] ?? "").split("/").filter(Boolean);
559
+ return parts.length === 2 && parts[0] === SEARCH_BASE_ROUTE && isShortListingIdentity(parts[1] ?? "");
560
+ }
561
+
549
562
  // ../search-url/path.ts
550
563
  function toArray(value) {
551
564
  if (value === void 0) return [];
@@ -642,6 +655,7 @@ function parseSearchPublicPath(pathname, dictionary = emptySearchUrlDictionary()
642
655
  if (segments.some((segment) => segment.toLowerCase().startsWith("id-"))) {
643
656
  return null;
644
657
  }
658
+ if (isShortListingPath(raw)) return null;
645
659
  const filters = {};
646
660
  const locationParts = [];
647
661
  const propertyTypes = [];
@@ -1016,9 +1030,9 @@ function pathnameOnly(pathname) {
1016
1030
  return String(pathname || "").split(/[?#]/)[0] || "/";
1017
1031
  }
1018
1032
  function isListingDetailPath(pathname) {
1019
- const parts = pathnameOnly(pathname).split("/").filter(Boolean);
1020
- const last = parts[parts.length - 1] || "";
1021
- return last.toLowerCase().startsWith("id-");
1033
+ const path = pathnameOnly(pathname);
1034
+ const last = path.split("/").filter(Boolean).pop() || "";
1035
+ return last.toLowerCase().startsWith("id-") || isShortListingPath(path);
1022
1036
  }
1023
1037
  function readPublicSearch(pathname, search, dictionary) {
1024
1038
  const pathFilters = parseSearchPublicPath2(pathnameOnly(pathname), dictionary) || {};
@@ -1949,7 +1963,7 @@ var LeadSubmitError = class extends Error {
1949
1963
  this.retryAfter = info.retryAfterSeconds ?? null;
1950
1964
  }
1951
1965
  };
1952
- var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1966
+ var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1953
1967
  var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1954
1968
  var NAME_RE = /^[^\d\s]{2,}.*$/;
1955
1969
  var MESSAGE_MAX = 2e3;
@@ -2001,7 +2015,7 @@ async function getLeadUi(options) {
2001
2015
  );
2002
2016
  }
2003
2017
  function assertListingId(listingId) {
2004
- if (!UUID_RE.test(listingId.trim())) {
2018
+ if (!UUID_RE2.test(listingId.trim())) {
2005
2019
  throw new LeadSubmitError(
2006
2020
  "Garagem SDK: listingId must be the listing UUID, not a path or code.",
2007
2021
  { code: "invalid_listing_id" }