@shoppexio/builder-contracts 0.1.13 → 0.1.14
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/preview-route.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Normalizes the storefront route visible inside a theme-preview iframe after the
|
|
3
3
|
* worker strips the `/s/:sessionId/:draftToken` prefix via history.replaceState.
|
|
4
4
|
*/
|
|
5
|
-
export declare function readPreviewStorefrontRoutePath(pathname: string, search?: string,
|
|
5
|
+
export declare function readPreviewStorefrontRoutePath(pathname: string, search?: string, _hash?: string): string | null;
|
|
6
6
|
//# sourceMappingURL=preview-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-route.d.ts","sourceRoot":"","sources":["../src/preview-route.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,MAAM,SAAK,EACX,
|
|
1
|
+
{"version":3,"file":"preview-route.d.ts","sourceRoot":"","sources":["../src/preview-route.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,MAAM,SAAK,EACX,KAAK,SAAK,GACT,MAAM,GAAG,IAAI,CAaf"}
|
package/dist/preview-route.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Normalizes the storefront route visible inside a theme-preview iframe after the
|
|
3
3
|
* worker strips the `/s/:sessionId/:draftToken` prefix via history.replaceState.
|
|
4
4
|
*/
|
|
5
|
-
export function readPreviewStorefrontRoutePath(pathname, search = '',
|
|
5
|
+
export function readPreviewStorefrontRoutePath(pathname, search = '', _hash = '') {
|
|
6
6
|
const path = pathname.trim() || '/';
|
|
7
7
|
if (path.includes('/__shoppex/')) {
|
|
8
8
|
return null;
|
|
@@ -12,5 +12,5 @@ export function readPreviewStorefrontRoutePath(pathname, search = '', hash = '')
|
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
const normalizedPath = path.replace(/\/+$/, '') || '/';
|
|
15
|
-
return `${normalizedPath}${search}
|
|
15
|
+
return `${normalizedPath}${search}`;
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -7,6 +7,11 @@ describe('readPreviewStorefrontRoutePath', () => {
|
|
|
7
7
|
.toBe('/products?category=fivem&sort=price-asc');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
test('omits hash fragments from storefront routes', () => {
|
|
11
|
+
expect(readPreviewStorefrontRoutePath('/products', '?category=fivem', '#faq'))
|
|
12
|
+
.toBe('/products?category=fivem');
|
|
13
|
+
});
|
|
14
|
+
|
|
10
15
|
test('normalizes trailing slashes on non-root paths', () => {
|
|
11
16
|
expect(readPreviewStorefrontRoutePath('/products/', '?page=2')).toBe('/products?page=2');
|
|
12
17
|
});
|
package/src/preview-route.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export function readPreviewStorefrontRoutePath(
|
|
6
6
|
pathname: string,
|
|
7
7
|
search = '',
|
|
8
|
-
|
|
8
|
+
_hash = '',
|
|
9
9
|
): string | null {
|
|
10
10
|
const path = pathname.trim() || '/';
|
|
11
11
|
if (path.includes('/__shoppex/')) {
|
|
@@ -18,5 +18,5 @@ export function readPreviewStorefrontRoutePath(
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const normalizedPath = path.replace(/\/+$/, '') || '/';
|
|
21
|
-
return `${normalizedPath}${search}
|
|
21
|
+
return `${normalizedPath}${search}`;
|
|
22
22
|
}
|