@beinformed/ui 1.63.0 → 1.63.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 +15 -0
- package/esm/react-server/__tests__/requestInformation.spec.js.flow +8 -7
- package/esm/react-server/requestInformation.js +16 -1
- package/esm/react-server/requestInformation.js.flow +15 -1
- package/esm/react-server/requestInformation.js.map +1 -1
- package/lib/react-server/requestInformation.js +16 -1
- package/lib/react-server/requestInformation.js.map +1 -1
- package/package.json +1 -1
- package/src/react-server/__tests__/requestInformation.spec.js +8 -7
- package/src/react-server/requestInformation.js +15 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.63.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.1...v1.63.2) (2025-08-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **server-request:** properly encode multi value options ([35cc4c9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/35cc4c9b5ec1fdcba7295c8f61ff1b7239500dfc))
|
|
11
|
+
* **server-request:** use URLSearchParam for proper encoding ([d43ab03](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d43ab03636b9031d0d0cda4b624f3f137d1dc828))
|
|
12
|
+
|
|
13
|
+
## [1.63.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.0...v1.63.1) (2025-07-04)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **server-request:** escape querystring ([d39da26](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d39da267eb9dc695718001fead168350ad542cec))
|
|
19
|
+
|
|
5
20
|
## [1.63.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.8...v1.63.0) (2025-07-02)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -92,7 +92,7 @@ describe("requestInformation", () => {
|
|
|
92
92
|
queryString: "q=hello world&filter=test",
|
|
93
93
|
});
|
|
94
94
|
expect(getFullRequestUrl(request)).toBe(
|
|
95
|
-
"/search?q
|
|
95
|
+
"/search?q=hello+world&filter=test",
|
|
96
96
|
);
|
|
97
97
|
});
|
|
98
98
|
|
|
@@ -120,7 +120,7 @@ describe("requestInformation", () => {
|
|
|
120
120
|
queryString: "name=John Doe & email=john@example.com",
|
|
121
121
|
});
|
|
122
122
|
expect(getFullRequestUrl(request)).toBe(
|
|
123
|
-
"/api/data?name%
|
|
123
|
+
"/api/data?name=John+Doe+&+email=john%40example.com",
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
|
|
@@ -144,24 +144,25 @@ describe("requestInformation", () => {
|
|
|
144
144
|
// Verify that Href constructor was called with the correct URL
|
|
145
145
|
expect(require("../../models/href/Href")).toHaveBeenCalledTimes(1);
|
|
146
146
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
147
|
-
"/products?id
|
|
147
|
+
"/products?id=123",
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
// Verify the returned object is an instance of the mock Href
|
|
151
|
-
expect(hrefInstance.url).toBe("/products?id
|
|
151
|
+
expect(hrefInstance.url).toBe("/products?id=123");
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
it("should handle complex URLs and pass them to Href", () => {
|
|
155
155
|
const request = createMockRequest({
|
|
156
156
|
pathInfo: "/search/results",
|
|
157
|
-
queryString:
|
|
157
|
+
queryString:
|
|
158
|
+
"q=javascript%20xss¶m=value&multi=option%201%2Coption2,option3",
|
|
158
159
|
});
|
|
159
160
|
const hrefInstance = getFullRequestHref(request);
|
|
160
161
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
161
|
-
"/search/results?q%
|
|
162
|
+
"/search/results?q=javascript+xss¶m=value&multi=option+1%2Coption2%2Coption3",
|
|
162
163
|
);
|
|
163
164
|
expect(hrefInstance.url).toBe(
|
|
164
|
-
"/search/results?q%
|
|
165
|
+
"/search/results?q=javascript+xss¶m=value&multi=option+1%2Coption2%2Coption3",
|
|
165
166
|
);
|
|
166
167
|
});
|
|
167
168
|
});
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
import _URLSearchParams from "@babel/runtime-corejs3/core-js-stable/url-search-params";
|
|
1
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
2
3
|
import Href from "../models/href/Href";
|
|
4
|
+
/**
|
|
5
|
+
*/
|
|
6
|
+
const encodeQueryString = queryString => {
|
|
7
|
+
if (!queryString) return "";
|
|
8
|
+
|
|
9
|
+
// Create a URLSearchParams object from the existing query string
|
|
10
|
+
// It handles all the splitting, decoding, and special characters automatically.
|
|
11
|
+
const params = new _URLSearchParams(queryString);
|
|
12
|
+
|
|
13
|
+
// Return the encoded query string
|
|
14
|
+
// toString() correctly re-encodes everything.
|
|
15
|
+
return params.toString();
|
|
16
|
+
};
|
|
17
|
+
|
|
3
18
|
/**
|
|
4
19
|
*/
|
|
5
20
|
export const getFullRequestUrl = request => {
|
|
@@ -8,7 +23,7 @@ export const getFullRequestUrl = request => {
|
|
|
8
23
|
let queryString = request.getQueryString();
|
|
9
24
|
pathInfo = _mapInstanceProperty(_context = pathInfo.split("/")).call(_context, segment => encodeURIComponent(segment)).join("/");
|
|
10
25
|
if (queryString) {
|
|
11
|
-
return `${pathInfo}?${
|
|
26
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
12
27
|
}
|
|
13
28
|
return pathInfo;
|
|
14
29
|
};
|
|
@@ -3,6 +3,20 @@ import Href from "../models/href/Href";
|
|
|
3
3
|
|
|
4
4
|
import type Locales from "../i18n/Locales";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
*/
|
|
8
|
+
const encodeQueryString = (queryString: string) => {
|
|
9
|
+
if (!queryString) return "";
|
|
10
|
+
|
|
11
|
+
// Create a URLSearchParams object from the existing query string
|
|
12
|
+
// It handles all the splitting, decoding, and special characters automatically.
|
|
13
|
+
const params = new URLSearchParams(queryString);
|
|
14
|
+
|
|
15
|
+
// Return the encoded query string
|
|
16
|
+
// toString() correctly re-encodes everything.
|
|
17
|
+
return params.toString();
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
21
|
*/
|
|
8
22
|
export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
@@ -15,7 +29,7 @@ export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
|
15
29
|
.join("/");
|
|
16
30
|
|
|
17
31
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
32
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
return pathInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInformation.js","names":["Href","getFullRequestUrl","request","_context","pathInfo","getPathInfo","
|
|
1
|
+
{"version":3,"file":"requestInformation.js","names":["Href","encodeQueryString","queryString","params","_URLSearchParams","toString","getFullRequestUrl","request","_context","pathInfo","getPathInfo","getQueryString","_mapInstanceProperty","split","call","segment","encodeURIComponent","join","getFullRequestHref","getCookieFromRequest","cookieName","getCookieByName","getPreferredLocale","locales","languageFromCookie","acceptLanguageHeader","getHeader","availableLocaleCodes"],"sources":["../../src/react-server/requestInformation.js"],"sourcesContent":["// @flow\nimport Href from \"../models/href/Href\";\n\nimport type Locales from \"../i18n/Locales\";\n\n/**\n */\nconst encodeQueryString = (queryString: string) => {\n if (!queryString) return \"\";\n\n // Create a URLSearchParams object from the existing query string\n // It handles all the splitting, decoding, and special characters automatically.\n const params = new URLSearchParams(queryString);\n\n // Return the encoded query string\n // toString() correctly re-encodes everything.\n return params.toString();\n};\n\n/**\n */\nexport const getFullRequestUrl = (request: HttpServletRequestJava): string => {\n let pathInfo = request.getPathInfo() || \"/\";\n let queryString = request.getQueryString();\n\n pathInfo = pathInfo\n .split(\"/\")\n .map((segment) => encodeURIComponent(segment))\n .join(\"/\");\n\n if (queryString) {\n return `${pathInfo}?${encodeQueryString(queryString)}`;\n }\n\n return pathInfo;\n};\n\n/**\n */\nexport const getFullRequestHref = (request: HttpServletRequestJava): Href =>\n new Href(getFullRequestUrl(request));\n\n/**\n */\nexport const getCookieFromRequest = (\n request: HttpServletRequestJava,\n cookieName: string,\n): null | string => {\n return request.getCookieByName(cookieName);\n};\n\n/**\n */\nexport const getPreferredLocale = (\n request: HttpServletRequestJava,\n locales: Locales,\n): void | string => {\n const languageFromCookie = getCookieFromRequest(request, \"locale\");\n const acceptLanguageHeader =\n languageFromCookie || request.getHeader(\"Accept-Language\");\n\n // when no accept language header or cookie present, get first locale code\n if (acceptLanguageHeader === null) {\n return locales.availableLocaleCodes[0];\n }\n\n return locales.getPreferredLocale(acceptLanguageHeader);\n};\n"],"mappings":";;AACA,OAAOA,IAAI,MAAM,qBAAqB;AAItC;AACA;AACA,MAAMC,iBAAiB,GAAIC,WAAmB,IAAK;EACjD,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;;EAE3B;EACA;EACA,MAAMC,MAAM,GAAG,IAAAC,gBAAA,CAAoBF,WAAW,CAAC;;EAE/C;EACA;EACA,OAAOC,MAAM,CAACE,QAAQ,CAAC,CAAC;AAC1B,CAAC;;AAED;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAIC,OAA+B,IAAa;EAAA,IAAAC,QAAA;EAC5E,IAAIC,QAAQ,GAAGF,OAAO,CAACG,WAAW,CAAC,CAAC,IAAI,GAAG;EAC3C,IAAIR,WAAW,GAAGK,OAAO,CAACI,cAAc,CAAC,CAAC;EAE1CF,QAAQ,GAAGG,oBAAA,CAAAJ,QAAA,GAAAC,QAAQ,CAChBI,KAAK,CAAC,GAAG,CAAC,EAAAC,IAAA,CAAAN,QAAA,EACLO,OAAO,IAAKC,kBAAkB,CAACD,OAAO,CAAC,CAAC,CAC7CE,IAAI,CAAC,GAAG,CAAC;EAEZ,IAAIf,WAAW,EAAE;IACf,OAAO,GAAGO,QAAQ,IAAIR,iBAAiB,CAACC,WAAW,CAAC,EAAE;EACxD;EAEA,OAAOO,QAAQ;AACjB,CAAC;;AAED;AACA;AACA,OAAO,MAAMS,kBAAkB,GAAIX,OAA+B,IAChE,IAAIP,IAAI,CAACM,iBAAiB,CAACC,OAAO,CAAC,CAAC;;AAEtC;AACA;AACA,OAAO,MAAMY,oBAAoB,GAAGA,CAClCZ,OAA+B,EAC/Ba,UAAkB,KACA;EAClB,OAAOb,OAAO,CAACc,eAAe,CAACD,UAAU,CAAC;AAC5C,CAAC;;AAED;AACA;AACA,OAAO,MAAME,kBAAkB,GAAGA,CAChCf,OAA+B,EAC/BgB,OAAgB,KACE;EAClB,MAAMC,kBAAkB,GAAGL,oBAAoB,CAACZ,OAAO,EAAE,QAAQ,CAAC;EAClE,MAAMkB,oBAAoB,GACxBD,kBAAkB,IAAIjB,OAAO,CAACmB,SAAS,CAAC,iBAAiB,CAAC;;EAE5D;EACA,IAAID,oBAAoB,KAAK,IAAI,EAAE;IACjC,OAAOF,OAAO,CAACI,oBAAoB,CAAC,CAAC,CAAC;EACxC;EAEA,OAAOJ,OAAO,CAACD,kBAAkB,CAACG,oBAAoB,CAAC;AACzD,CAAC","ignoreList":[]}
|
|
@@ -5,8 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getPreferredLocale = exports.getFullRequestUrl = exports.getFullRequestHref = exports.getCookieFromRequest = void 0;
|
|
8
|
+
var _urlSearchParams = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url-search-params"));
|
|
8
9
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
9
10
|
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
11
|
+
/**
|
|
12
|
+
*/
|
|
13
|
+
const encodeQueryString = queryString => {
|
|
14
|
+
if (!queryString) return "";
|
|
15
|
+
|
|
16
|
+
// Create a URLSearchParams object from the existing query string
|
|
17
|
+
// It handles all the splitting, decoding, and special characters automatically.
|
|
18
|
+
const params = new _urlSearchParams.default(queryString);
|
|
19
|
+
|
|
20
|
+
// Return the encoded query string
|
|
21
|
+
// toString() correctly re-encodes everything.
|
|
22
|
+
return params.toString();
|
|
23
|
+
};
|
|
24
|
+
|
|
10
25
|
/**
|
|
11
26
|
*/
|
|
12
27
|
const getFullRequestUrl = request => {
|
|
@@ -15,7 +30,7 @@ const getFullRequestUrl = request => {
|
|
|
15
30
|
let queryString = request.getQueryString();
|
|
16
31
|
pathInfo = (0, _map.default)(_context = pathInfo.split("/")).call(_context, segment => encodeURIComponent(segment)).join("/");
|
|
17
32
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
33
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
34
|
}
|
|
20
35
|
return pathInfo;
|
|
21
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInformation.js","names":["_Href","_interopRequireDefault","require","getFullRequestUrl","request","_context","pathInfo","getPathInfo","
|
|
1
|
+
{"version":3,"file":"requestInformation.js","names":["_Href","_interopRequireDefault","require","encodeQueryString","queryString","params","_urlSearchParams","default","toString","getFullRequestUrl","request","_context","pathInfo","getPathInfo","getQueryString","_map","split","call","segment","encodeURIComponent","join","exports","getFullRequestHref","Href","getCookieFromRequest","cookieName","getCookieByName","getPreferredLocale","locales","languageFromCookie","acceptLanguageHeader","getHeader","availableLocaleCodes"],"sources":["../../src/react-server/requestInformation.js"],"sourcesContent":["// @flow\nimport Href from \"../models/href/Href\";\n\nimport type Locales from \"../i18n/Locales\";\n\n/**\n */\nconst encodeQueryString = (queryString: string) => {\n if (!queryString) return \"\";\n\n // Create a URLSearchParams object from the existing query string\n // It handles all the splitting, decoding, and special characters automatically.\n const params = new URLSearchParams(queryString);\n\n // Return the encoded query string\n // toString() correctly re-encodes everything.\n return params.toString();\n};\n\n/**\n */\nexport const getFullRequestUrl = (request: HttpServletRequestJava): string => {\n let pathInfo = request.getPathInfo() || \"/\";\n let queryString = request.getQueryString();\n\n pathInfo = pathInfo\n .split(\"/\")\n .map((segment) => encodeURIComponent(segment))\n .join(\"/\");\n\n if (queryString) {\n return `${pathInfo}?${encodeQueryString(queryString)}`;\n }\n\n return pathInfo;\n};\n\n/**\n */\nexport const getFullRequestHref = (request: HttpServletRequestJava): Href =>\n new Href(getFullRequestUrl(request));\n\n/**\n */\nexport const getCookieFromRequest = (\n request: HttpServletRequestJava,\n cookieName: string,\n): null | string => {\n return request.getCookieByName(cookieName);\n};\n\n/**\n */\nexport const getPreferredLocale = (\n request: HttpServletRequestJava,\n locales: Locales,\n): void | string => {\n const languageFromCookie = getCookieFromRequest(request, \"locale\");\n const acceptLanguageHeader =\n languageFromCookie || request.getHeader(\"Accept-Language\");\n\n // when no accept language header or cookie present, get first locale code\n if (acceptLanguageHeader === null) {\n return locales.availableLocaleCodes[0];\n }\n\n return locales.getPreferredLocale(acceptLanguageHeader);\n};\n"],"mappings":";;;;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA,MAAMC,iBAAiB,GAAIC,WAAmB,IAAK;EACjD,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;;EAE3B;EACA;EACA,MAAMC,MAAM,GAAG,IAAAC,gBAAA,CAAAC,OAAA,CAAoBH,WAAW,CAAC;;EAE/C;EACA;EACA,OAAOC,MAAM,CAACG,QAAQ,CAAC,CAAC;AAC1B,CAAC;;AAED;AACA;AACO,MAAMC,iBAAiB,GAAIC,OAA+B,IAAa;EAAA,IAAAC,QAAA;EAC5E,IAAIC,QAAQ,GAAGF,OAAO,CAACG,WAAW,CAAC,CAAC,IAAI,GAAG;EAC3C,IAAIT,WAAW,GAAGM,OAAO,CAACI,cAAc,CAAC,CAAC;EAE1CF,QAAQ,GAAG,IAAAG,IAAA,CAAAR,OAAA,EAAAI,QAAA,GAAAC,QAAQ,CAChBI,KAAK,CAAC,GAAG,CAAC,EAAAC,IAAA,CAAAN,QAAA,EACLO,OAAO,IAAKC,kBAAkB,CAACD,OAAO,CAAC,CAAC,CAC7CE,IAAI,CAAC,GAAG,CAAC;EAEZ,IAAIhB,WAAW,EAAE;IACf,OAAO,GAAGQ,QAAQ,IAAIT,iBAAiB,CAACC,WAAW,CAAC,EAAE;EACxD;EAEA,OAAOQ,QAAQ;AACjB,CAAC;;AAED;AACA;AADAS,OAAA,CAAAZ,iBAAA,GAAAA,iBAAA;AAEO,MAAMa,kBAAkB,GAAIZ,OAA+B,IAChE,IAAIa,aAAI,CAACd,iBAAiB,CAACC,OAAO,CAAC,CAAC;;AAEtC;AACA;AADAW,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAEO,MAAME,oBAAoB,GAAGA,CAClCd,OAA+B,EAC/Be,UAAkB,KACA;EAClB,OAAOf,OAAO,CAACgB,eAAe,CAACD,UAAU,CAAC;AAC5C,CAAC;;AAED;AACA;AADAJ,OAAA,CAAAG,oBAAA,GAAAA,oBAAA;AAEO,MAAMG,kBAAkB,GAAGA,CAChCjB,OAA+B,EAC/BkB,OAAgB,KACE;EAClB,MAAMC,kBAAkB,GAAGL,oBAAoB,CAACd,OAAO,EAAE,QAAQ,CAAC;EAClE,MAAMoB,oBAAoB,GACxBD,kBAAkB,IAAInB,OAAO,CAACqB,SAAS,CAAC,iBAAiB,CAAC;;EAE5D;EACA,IAAID,oBAAoB,KAAK,IAAI,EAAE;IACjC,OAAOF,OAAO,CAACI,oBAAoB,CAAC,CAAC,CAAC;EACxC;EAEA,OAAOJ,OAAO,CAACD,kBAAkB,CAACG,oBAAoB,CAAC;AACzD,CAAC;AAACT,OAAA,CAAAM,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -92,7 +92,7 @@ describe("requestInformation", () => {
|
|
|
92
92
|
queryString: "q=hello world&filter=test",
|
|
93
93
|
});
|
|
94
94
|
expect(getFullRequestUrl(request)).toBe(
|
|
95
|
-
"/search?q
|
|
95
|
+
"/search?q=hello+world&filter=test",
|
|
96
96
|
);
|
|
97
97
|
});
|
|
98
98
|
|
|
@@ -120,7 +120,7 @@ describe("requestInformation", () => {
|
|
|
120
120
|
queryString: "name=John Doe & email=john@example.com",
|
|
121
121
|
});
|
|
122
122
|
expect(getFullRequestUrl(request)).toBe(
|
|
123
|
-
"/api/data?name%
|
|
123
|
+
"/api/data?name=John+Doe+&+email=john%40example.com",
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
|
|
@@ -144,24 +144,25 @@ describe("requestInformation", () => {
|
|
|
144
144
|
// Verify that Href constructor was called with the correct URL
|
|
145
145
|
expect(require("../../models/href/Href")).toHaveBeenCalledTimes(1);
|
|
146
146
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
147
|
-
"/products?id
|
|
147
|
+
"/products?id=123",
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
// Verify the returned object is an instance of the mock Href
|
|
151
|
-
expect(hrefInstance.url).toBe("/products?id
|
|
151
|
+
expect(hrefInstance.url).toBe("/products?id=123");
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
it("should handle complex URLs and pass them to Href", () => {
|
|
155
155
|
const request = createMockRequest({
|
|
156
156
|
pathInfo: "/search/results",
|
|
157
|
-
queryString:
|
|
157
|
+
queryString:
|
|
158
|
+
"q=javascript%20xss¶m=value&multi=option%201%2Coption2,option3",
|
|
158
159
|
});
|
|
159
160
|
const hrefInstance = getFullRequestHref(request);
|
|
160
161
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
161
|
-
"/search/results?q%
|
|
162
|
+
"/search/results?q=javascript+xss¶m=value&multi=option+1%2Coption2%2Coption3",
|
|
162
163
|
);
|
|
163
164
|
expect(hrefInstance.url).toBe(
|
|
164
|
-
"/search/results?q%
|
|
165
|
+
"/search/results?q=javascript+xss¶m=value&multi=option+1%2Coption2%2Coption3",
|
|
165
166
|
);
|
|
166
167
|
});
|
|
167
168
|
});
|
|
@@ -3,6 +3,20 @@ import Href from "../models/href/Href";
|
|
|
3
3
|
|
|
4
4
|
import type Locales from "../i18n/Locales";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
*/
|
|
8
|
+
const encodeQueryString = (queryString: string) => {
|
|
9
|
+
if (!queryString) return "";
|
|
10
|
+
|
|
11
|
+
// Create a URLSearchParams object from the existing query string
|
|
12
|
+
// It handles all the splitting, decoding, and special characters automatically.
|
|
13
|
+
const params = new URLSearchParams(queryString);
|
|
14
|
+
|
|
15
|
+
// Return the encoded query string
|
|
16
|
+
// toString() correctly re-encodes everything.
|
|
17
|
+
return params.toString();
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
21
|
*/
|
|
8
22
|
export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
@@ -15,7 +29,7 @@ export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
|
15
29
|
.join("/");
|
|
16
30
|
|
|
17
31
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
32
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
return pathInfo;
|