@homecode/ui 5.20.11 → 5.20.12
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.
|
@@ -12,15 +12,22 @@ function parseQueryParams(qs) {
|
|
|
12
12
|
}
|
|
13
13
|
function stringifyQueryParams(params) {
|
|
14
14
|
return Object.entries(params)
|
|
15
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
15
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
16
16
|
.join('&');
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Path with `queryParams` applied. A query already in `path`
|
|
20
|
+
* (`go('/storage?folder=1')`) is kept; `queryParams` override its keys.
|
|
21
|
+
*/
|
|
18
22
|
function applyQueryParams(path, queryParams) {
|
|
19
|
-
const clearPath = path.replace(/\?.*/, '/');
|
|
20
23
|
if (typeof queryParams === 'string')
|
|
21
24
|
return queryParams;
|
|
22
|
-
const
|
|
23
|
-
|
|
25
|
+
const [clearPath, pathQuery = ''] = path.split('?');
|
|
26
|
+
const query = {
|
|
27
|
+
...Object.fromEntries(new URLSearchParams(pathQuery)),
|
|
28
|
+
...queryParams,
|
|
29
|
+
};
|
|
30
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
24
31
|
if (value === false)
|
|
25
32
|
delete query[key];
|
|
26
33
|
else
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export declare function parseQueryParams(qs?: string): Record<string, string>;
|
|
2
2
|
export declare function stringifyQueryParams(params: Record<string, string>): string;
|
|
3
|
+
/**
|
|
4
|
+
* Path with `queryParams` applied. A query already in `path`
|
|
5
|
+
* (`go('/storage?folder=1')`) is kept; `queryParams` override its keys.
|
|
6
|
+
*/
|
|
3
7
|
export declare function applyQueryParams(path: any, queryParams: Record<string, any> | string): string;
|
|
4
8
|
export declare const setSSRQueryParams: (params: any) => void;
|
|
5
9
|
export declare const queryParams: Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|