@soleil-se/app-util 5.5.0 → 5.5.2
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/CHANGELOG.md +8 -0
- package/client/url-params/index.js +7 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.5.2] - 2023-08-28
|
|
9
|
+
|
|
10
|
+
- Respect hash when updating URL parameters with `updateUrlParams` and `setUrlParams`.
|
|
11
|
+
|
|
12
|
+
## [5.5.1] - 2023-08-25
|
|
13
|
+
|
|
14
|
+
- Don't remove `?` from `location.search` when parsing parameters in `getUrlParams` and `updateUrlParams`.
|
|
15
|
+
|
|
8
16
|
## [5.5.0] - 2023-08-25
|
|
9
17
|
|
|
10
18
|
- Remove abort controllers in `fetchJson` since it's better to handle this seperatly case by case.
|
|
@@ -9,14 +9,16 @@ const isEmpty = (obj) => Object.keys(obj).length === 0 && obj.constructor === Ob
|
|
|
9
9
|
* @param {Boolean} [options.scoped = false] If parameter keys should be scoped to current app.
|
|
10
10
|
*/
|
|
11
11
|
export function setUrlParams(params) {
|
|
12
|
-
|
|
12
|
+
const path = (isEmpty(params) ? window.location.pathname : `?${stringifyParams(params)}`);
|
|
13
|
+
const { hash = '' } = window.location;
|
|
14
|
+
window.history.replaceState({}, '', path + hash);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Get query parameter from the url-field.
|
|
17
19
|
*/
|
|
18
20
|
export function getUrlParam(key) {
|
|
19
|
-
const params = parseParams(window.location.search
|
|
21
|
+
const params = parseParams(window.location.search);
|
|
20
22
|
return params[key];
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -24,7 +26,7 @@ export function getUrlParam(key) {
|
|
|
24
26
|
* Get query parameters from the url-field.
|
|
25
27
|
*/
|
|
26
28
|
export function getUrlParams() {
|
|
27
|
-
const params = parseParams(window.location.search
|
|
29
|
+
const params = parseParams(window.location.search);
|
|
28
30
|
return params;
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -32,7 +34,8 @@ export function getUrlParams() {
|
|
|
32
34
|
* Clear query parameters in the url-field.
|
|
33
35
|
*/
|
|
34
36
|
export function clearUrlParams() {
|
|
35
|
-
|
|
37
|
+
const { pathname, hash = '' } = window.location;
|
|
38
|
+
window.history.replaceState({}, '', pathname + hash);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/app-util",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.2",
|
|
4
4
|
"description": "Utility and rendering functions for WebApps.",
|
|
5
5
|
"main": "./common/index.js",
|
|
6
6
|
"author": "Soleil AB",
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@sitevision/api": "*"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "e132d21089258c678eab7a8a3387edabe1f6534b",
|
|
18
18
|
"dependencies": {}
|
|
19
19
|
}
|