@wix/headless-stores 0.0.47 → 0.0.48
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.
|
@@ -141,21 +141,17 @@ function updateUrlWithSearchState(searchState) {
|
|
|
141
141
|
}
|
|
142
142
|
// Handle URL path construction with category
|
|
143
143
|
let baseUrl = window.location.pathname;
|
|
144
|
-
// If categorySlug is provided,
|
|
144
|
+
// If categorySlug is provided, replace the last path segment (which represents the category)
|
|
145
145
|
if (categorySlug) {
|
|
146
|
-
// Find if there's already a /category/ segment in the current path
|
|
147
146
|
const pathSegments = baseUrl.split("/").filter(Boolean);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
pathSegments[categoryIndex + 1] = categorySlug;
|
|
147
|
+
if (pathSegments.length > 0) {
|
|
148
|
+
// Replace the last segment with the new category slug
|
|
149
|
+
pathSegments[pathSegments.length - 1] = categorySlug;
|
|
152
150
|
baseUrl = "/" + pathSegments.join("/");
|
|
153
151
|
}
|
|
154
152
|
else {
|
|
155
|
-
//
|
|
156
|
-
baseUrl =
|
|
157
|
-
? `${baseUrl}category/${categorySlug}`
|
|
158
|
-
: `${baseUrl}/category/${categorySlug}`;
|
|
153
|
+
// If no segments, just use the category slug
|
|
154
|
+
baseUrl = `/${categorySlug}`;
|
|
159
155
|
}
|
|
160
156
|
}
|
|
161
157
|
// Build the new URL
|
|
@@ -141,21 +141,17 @@ function updateUrlWithSearchState(searchState) {
|
|
|
141
141
|
}
|
|
142
142
|
// Handle URL path construction with category
|
|
143
143
|
let baseUrl = window.location.pathname;
|
|
144
|
-
// If categorySlug is provided,
|
|
144
|
+
// If categorySlug is provided, replace the last path segment (which represents the category)
|
|
145
145
|
if (categorySlug) {
|
|
146
|
-
// Find if there's already a /category/ segment in the current path
|
|
147
146
|
const pathSegments = baseUrl.split("/").filter(Boolean);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
pathSegments[categoryIndex + 1] = categorySlug;
|
|
147
|
+
if (pathSegments.length > 0) {
|
|
148
|
+
// Replace the last segment with the new category slug
|
|
149
|
+
pathSegments[pathSegments.length - 1] = categorySlug;
|
|
152
150
|
baseUrl = "/" + pathSegments.join("/");
|
|
153
151
|
}
|
|
154
152
|
else {
|
|
155
|
-
//
|
|
156
|
-
baseUrl =
|
|
157
|
-
? `${baseUrl}category/${categorySlug}`
|
|
158
|
-
: `${baseUrl}/category/${categorySlug}`;
|
|
153
|
+
// If no segments, just use the category slug
|
|
154
|
+
baseUrl = `/${categorySlug}`;
|
|
159
155
|
}
|
|
160
156
|
}
|
|
161
157
|
// Build the new URL
|