@lwrjs/shared-utils 0.11.6 → 0.12.0-alpha.1
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/build/cjs/urls.cjs +13 -1
- package/build/es/urls.d.ts +2 -1
- package/build/es/urls.js +16 -1
- package/package.json +4 -4
package/build/cjs/urls.cjs
CHANGED
|
@@ -39,7 +39,8 @@ var import_path = __toModule(require("path"));
|
|
|
39
39
|
var CONFIG_SUFFIX = "/config.js";
|
|
40
40
|
var SIGNATURE_SIGIL = "s";
|
|
41
41
|
function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
|
|
42
|
-
const
|
|
42
|
+
const url = routeInfo.url + sortedQueryParamString(routeInfo.query);
|
|
43
|
+
const encodeUrl = `-${encodeURIComponent(url)}-`;
|
|
43
44
|
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
44
45
|
const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : "";
|
|
45
46
|
return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
|
|
@@ -125,3 +126,14 @@ function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
|
|
|
125
126
|
url.searchParams.set(paramName, paramValue);
|
|
126
127
|
return url.pathname + url.search;
|
|
127
128
|
}
|
|
129
|
+
function sortedQueryParamString(query) {
|
|
130
|
+
if (!query) {
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
const keys = Object.keys(query);
|
|
134
|
+
if (!keys || keys.length === 0) {
|
|
135
|
+
return "";
|
|
136
|
+
}
|
|
137
|
+
const sortedKeys = keys.sort();
|
|
138
|
+
return "?" + sortedKeys.map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`).join("&");
|
|
139
|
+
}
|
package/build/es/urls.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { I18NConfig, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
|
|
1
|
+
import type { I18NConfig, RuntimeEnvironment, RuntimeParams, ViewRequestQs } from '@lwrjs/types';
|
|
2
2
|
export declare function getClientBootstrapConfigurationUri(routeInfo: {
|
|
3
3
|
id: string;
|
|
4
4
|
url: string;
|
|
5
|
+
query?: ViewRequestQs;
|
|
5
6
|
}, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): string;
|
|
6
7
|
export declare function decodeViewPath(encodedViewPath: string): string;
|
|
7
8
|
export declare function getClientBootstrapConfigurationUriPrefix(routeInfo: {
|
package/build/es/urls.js
CHANGED
|
@@ -5,7 +5,8 @@ const SIGNATURE_SIGIL = 's';
|
|
|
5
5
|
export function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
|
|
6
6
|
// Add extra dashes around encoded path so when saved as static file leading and
|
|
7
7
|
// trailing slashes are preserved as file path.
|
|
8
|
-
const
|
|
8
|
+
const url = routeInfo.url + sortedQueryParamString(routeInfo.query);
|
|
9
|
+
const encodeUrl = `-${encodeURIComponent(url)}-`;
|
|
9
10
|
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
10
11
|
const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : '';
|
|
11
12
|
return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
|
|
@@ -124,4 +125,18 @@ function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
|
|
|
124
125
|
// Get the modified URI with the query parameter
|
|
125
126
|
return url.pathname + url.search;
|
|
126
127
|
}
|
|
128
|
+
function sortedQueryParamString(query) {
|
|
129
|
+
if (!query) {
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
132
|
+
const keys = Object.keys(query);
|
|
133
|
+
if (!keys || keys.length === 0) {
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
const sortedKeys = keys.sort();
|
|
137
|
+
return ('?' +
|
|
138
|
+
sortedKeys
|
|
139
|
+
.map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
|
|
140
|
+
.join('&'));
|
|
141
|
+
}
|
|
127
142
|
//# sourceMappingURL=urls.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.12.0-alpha.1",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build/**/*.d.ts"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@lwrjs/diagnostics": "0.
|
|
40
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.1",
|
|
41
41
|
"es-module-lexer": "^1.3.0",
|
|
42
42
|
"fast-json-stable-stringify": "^2.1.0",
|
|
43
43
|
"magic-string": "^0.30.0",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"slugify": "^1.4.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@lwrjs/types": "0.
|
|
53
|
+
"@lwrjs/types": "0.12.0-alpha.1",
|
|
54
54
|
"@types/mime-types": "2.1.1",
|
|
55
55
|
"@types/path-to-regexp": "^1.7.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=16.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "138cc3716e923d0367e8279aaf2d6be21e74f440"
|
|
61
61
|
}
|