@wix/headless-stores 0.0.46 → 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,10 +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
|
-
|
|
147
|
-
|
|
146
|
+
const pathSegments = baseUrl.split("/").filter(Boolean);
|
|
147
|
+
if (pathSegments.length > 0) {
|
|
148
|
+
// Replace the last segment with the new category slug
|
|
149
|
+
pathSegments[pathSegments.length - 1] = categorySlug;
|
|
150
|
+
baseUrl = "/" + pathSegments.join("/");
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// If no segments, just use the category slug
|
|
154
|
+
baseUrl = `/${categorySlug}`;
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
// Build the new URL
|
|
@@ -141,10 +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
|
-
|
|
147
|
-
|
|
146
|
+
const pathSegments = baseUrl.split("/").filter(Boolean);
|
|
147
|
+
if (pathSegments.length > 0) {
|
|
148
|
+
// Replace the last segment with the new category slug
|
|
149
|
+
pathSegments[pathSegments.length - 1] = categorySlug;
|
|
150
|
+
baseUrl = "/" + pathSegments.join("/");
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// If no segments, just use the category slug
|
|
154
|
+
baseUrl = `/${categorySlug}`;
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
// Build the new URL
|