@beinformed/ui 1.63.0 → 1.63.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/CHANGELOG.md +7 -0
- package/esm/react-server/__tests__/requestInformation.spec.js.flow +6 -6
- package/esm/react-server/requestInformation.js +17 -1
- package/esm/react-server/requestInformation.js.flow +18 -1
- package/esm/react-server/requestInformation.js.map +1 -1
- package/lib/react-server/requestInformation.js +17 -1
- package/lib/react-server/requestInformation.js.map +1 -1
- package/package.json +1 -1
- package/src/react-server/__tests__/requestInformation.spec.js +6 -6
- package/src/react-server/requestInformation.js +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.0...v1.63.1) (2025-07-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **server-request:** escape querystring ([d39da26](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d39da267eb9dc695718001fead168350ad542cec))
|
|
11
|
+
|
|
5
12
|
## [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
13
|
|
|
7
14
|
|
|
@@ -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%20world&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%20Doe%20&%20email=john%40example.com",
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
|
|
@@ -144,11 +144,11 @@ 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", () => {
|
|
@@ -158,10 +158,10 @@ describe("requestInformation", () => {
|
|
|
158
158
|
});
|
|
159
159
|
const hrefInstance = getFullRequestHref(request);
|
|
160
160
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
161
|
-
"/search/results?q%
|
|
161
|
+
"/search/results?q=javascript%2520xss¶m=value",
|
|
162
162
|
);
|
|
163
163
|
expect(hrefInstance.url).toBe(
|
|
164
|
-
"/search/results?q%
|
|
164
|
+
"/search/results?q=javascript%2520xss¶m=value",
|
|
165
165
|
);
|
|
166
166
|
});
|
|
167
167
|
});
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
2
2
|
import Href from "../models/href/Href";
|
|
3
|
+
/**
|
|
4
|
+
*/
|
|
5
|
+
const encodeQueryString = queryString => {
|
|
6
|
+
if (!queryString) return "";
|
|
7
|
+
const params = [];
|
|
8
|
+
queryString.split("&").forEach(part => {
|
|
9
|
+
const [key, value] = part.split("=");
|
|
10
|
+
if (key && value) {
|
|
11
|
+
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
12
|
+
} else if (key) {
|
|
13
|
+
params.push(encodeURIComponent(key));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return params.join("&");
|
|
17
|
+
};
|
|
18
|
+
|
|
3
19
|
/**
|
|
4
20
|
*/
|
|
5
21
|
export const getFullRequestUrl = request => {
|
|
@@ -8,7 +24,7 @@ export const getFullRequestUrl = request => {
|
|
|
8
24
|
let queryString = request.getQueryString();
|
|
9
25
|
pathInfo = _mapInstanceProperty(_context = pathInfo.split("/")).call(_context, segment => encodeURIComponent(segment)).join("/");
|
|
10
26
|
if (queryString) {
|
|
11
|
-
return `${pathInfo}?${
|
|
27
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
12
28
|
}
|
|
13
29
|
return pathInfo;
|
|
14
30
|
};
|
|
@@ -3,6 +3,23 @@ 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
|
+
const params = [];
|
|
12
|
+
queryString.split("&").forEach((part) => {
|
|
13
|
+
const [key, value] = part.split("=");
|
|
14
|
+
if (key && value) {
|
|
15
|
+
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
16
|
+
} else if (key) {
|
|
17
|
+
params.push(encodeURIComponent(key));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return params.join("&");
|
|
21
|
+
};
|
|
22
|
+
|
|
6
23
|
/**
|
|
7
24
|
*/
|
|
8
25
|
export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
@@ -15,7 +32,7 @@ export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
|
15
32
|
.join("/");
|
|
16
33
|
|
|
17
34
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
35
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
return pathInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInformation.js","names":["Href","
|
|
1
|
+
{"version":3,"file":"requestInformation.js","names":["Href","encodeQueryString","queryString","params","split","forEach","part","key","value","push","encodeURIComponent","join","getFullRequestUrl","request","_context","pathInfo","getPathInfo","getQueryString","_mapInstanceProperty","call","segment","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 const params = [];\n queryString.split(\"&\").forEach((part) => {\n const [key, value] = part.split(\"=\");\n if (key && value) {\n params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);\n } else if (key) {\n params.push(encodeURIComponent(key));\n }\n });\n return params.join(\"&\");\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,MAAMC,MAAM,GAAG,EAAE;EACjBD,WAAW,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,OAAO,CAAEC,IAAI,IAAK;IACvC,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAGF,IAAI,CAACF,KAAK,CAAC,GAAG,CAAC;IACpC,IAAIG,GAAG,IAAIC,KAAK,EAAE;MAChBL,MAAM,CAACM,IAAI,CAAC,GAAGC,kBAAkB,CAACH,GAAG,CAAC,IAAIG,kBAAkB,CAACF,KAAK,CAAC,EAAE,CAAC;IACxE,CAAC,MAAM,IAAID,GAAG,EAAE;MACdJ,MAAM,CAACM,IAAI,CAACC,kBAAkB,CAACH,GAAG,CAAC,CAAC;IACtC;EACF,CAAC,CAAC;EACF,OAAOJ,MAAM,CAACQ,IAAI,CAAC,GAAG,CAAC;AACzB,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,IAAId,WAAW,GAAGW,OAAO,CAACI,cAAc,CAAC,CAAC;EAE1CF,QAAQ,GAAGG,oBAAA,CAAAJ,QAAA,GAAAC,QAAQ,CAChBX,KAAK,CAAC,GAAG,CAAC,EAAAe,IAAA,CAAAL,QAAA,EACLM,OAAO,IAAKV,kBAAkB,CAACU,OAAO,CAAC,CAAC,CAC7CT,IAAI,CAAC,GAAG,CAAC;EAEZ,IAAIT,WAAW,EAAE;IACf,OAAO,GAAGa,QAAQ,IAAId,iBAAiB,CAACC,WAAW,CAAC,EAAE;EACxD;EAEA,OAAOa,QAAQ;AACjB,CAAC;;AAED;AACA;AACA,OAAO,MAAMM,kBAAkB,GAAIR,OAA+B,IAChE,IAAIb,IAAI,CAACY,iBAAiB,CAACC,OAAO,CAAC,CAAC;;AAEtC;AACA;AACA,OAAO,MAAMS,oBAAoB,GAAGA,CAClCT,OAA+B,EAC/BU,UAAkB,KACA;EAClB,OAAOV,OAAO,CAACW,eAAe,CAACD,UAAU,CAAC;AAC5C,CAAC;;AAED;AACA;AACA,OAAO,MAAME,kBAAkB,GAAGA,CAChCZ,OAA+B,EAC/Ba,OAAgB,KACE;EAClB,MAAMC,kBAAkB,GAAGL,oBAAoB,CAACT,OAAO,EAAE,QAAQ,CAAC;EAClE,MAAMe,oBAAoB,GACxBD,kBAAkB,IAAId,OAAO,CAACgB,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":[]}
|
|
@@ -7,6 +7,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getPreferredLocale = exports.getFullRequestUrl = exports.getFullRequestHref = exports.getCookieFromRequest = void 0;
|
|
8
8
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
9
9
|
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
10
|
+
/**
|
|
11
|
+
*/
|
|
12
|
+
const encodeQueryString = queryString => {
|
|
13
|
+
if (!queryString) return "";
|
|
14
|
+
const params = [];
|
|
15
|
+
queryString.split("&").forEach(part => {
|
|
16
|
+
const [key, value] = part.split("=");
|
|
17
|
+
if (key && value) {
|
|
18
|
+
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
19
|
+
} else if (key) {
|
|
20
|
+
params.push(encodeURIComponent(key));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return params.join("&");
|
|
24
|
+
};
|
|
25
|
+
|
|
10
26
|
/**
|
|
11
27
|
*/
|
|
12
28
|
const getFullRequestUrl = request => {
|
|
@@ -15,7 +31,7 @@ const getFullRequestUrl = request => {
|
|
|
15
31
|
let queryString = request.getQueryString();
|
|
16
32
|
pathInfo = (0, _map.default)(_context = pathInfo.split("/")).call(_context, segment => encodeURIComponent(segment)).join("/");
|
|
17
33
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
34
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
35
|
}
|
|
20
36
|
return pathInfo;
|
|
21
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInformation.js","names":["_Href","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"requestInformation.js","names":["_Href","_interopRequireDefault","require","encodeQueryString","queryString","params","split","forEach","part","key","value","push","encodeURIComponent","join","getFullRequestUrl","request","_context","pathInfo","getPathInfo","getQueryString","_map","default","call","segment","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 const params = [];\n queryString.split(\"&\").forEach((part) => {\n const [key, value] = part.split(\"=\");\n if (key && value) {\n params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);\n } else if (key) {\n params.push(encodeURIComponent(key));\n }\n });\n return params.join(\"&\");\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,MAAMC,MAAM,GAAG,EAAE;EACjBD,WAAW,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,OAAO,CAAEC,IAAI,IAAK;IACvC,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAGF,IAAI,CAACF,KAAK,CAAC,GAAG,CAAC;IACpC,IAAIG,GAAG,IAAIC,KAAK,EAAE;MAChBL,MAAM,CAACM,IAAI,CAAC,GAAGC,kBAAkB,CAACH,GAAG,CAAC,IAAIG,kBAAkB,CAACF,KAAK,CAAC,EAAE,CAAC;IACxE,CAAC,MAAM,IAAID,GAAG,EAAE;MACdJ,MAAM,CAACM,IAAI,CAACC,kBAAkB,CAACH,GAAG,CAAC,CAAC;IACtC;EACF,CAAC,CAAC;EACF,OAAOJ,MAAM,CAACQ,IAAI,CAAC,GAAG,CAAC;AACzB,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,IAAId,WAAW,GAAGW,OAAO,CAACI,cAAc,CAAC,CAAC;EAE1CF,QAAQ,GAAG,IAAAG,IAAA,CAAAC,OAAA,EAAAL,QAAA,GAAAC,QAAQ,CAChBX,KAAK,CAAC,GAAG,CAAC,EAAAgB,IAAA,CAAAN,QAAA,EACLO,OAAO,IAAKX,kBAAkB,CAACW,OAAO,CAAC,CAAC,CAC7CV,IAAI,CAAC,GAAG,CAAC;EAEZ,IAAIT,WAAW,EAAE;IACf,OAAO,GAAGa,QAAQ,IAAId,iBAAiB,CAACC,WAAW,CAAC,EAAE;EACxD;EAEA,OAAOa,QAAQ;AACjB,CAAC;;AAED;AACA;AADAO,OAAA,CAAAV,iBAAA,GAAAA,iBAAA;AAEO,MAAMW,kBAAkB,GAAIV,OAA+B,IAChE,IAAIW,aAAI,CAACZ,iBAAiB,CAACC,OAAO,CAAC,CAAC;;AAEtC;AACA;AADAS,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAEO,MAAME,oBAAoB,GAAGA,CAClCZ,OAA+B,EAC/Ba,UAAkB,KACA;EAClB,OAAOb,OAAO,CAACc,eAAe,CAACD,UAAU,CAAC;AAC5C,CAAC;;AAED;AACA;AADAJ,OAAA,CAAAG,oBAAA,GAAAA,oBAAA;AAEO,MAAMG,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;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%20world&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%20Doe%20&%20email=john%40example.com",
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
|
|
@@ -144,11 +144,11 @@ 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", () => {
|
|
@@ -158,10 +158,10 @@ describe("requestInformation", () => {
|
|
|
158
158
|
});
|
|
159
159
|
const hrefInstance = getFullRequestHref(request);
|
|
160
160
|
expect(require("../../models/href/Href")).toHaveBeenCalledWith(
|
|
161
|
-
"/search/results?q%
|
|
161
|
+
"/search/results?q=javascript%2520xss¶m=value",
|
|
162
162
|
);
|
|
163
163
|
expect(hrefInstance.url).toBe(
|
|
164
|
-
"/search/results?q%
|
|
164
|
+
"/search/results?q=javascript%2520xss¶m=value",
|
|
165
165
|
);
|
|
166
166
|
});
|
|
167
167
|
});
|
|
@@ -3,6 +3,23 @@ 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
|
+
const params = [];
|
|
12
|
+
queryString.split("&").forEach((part) => {
|
|
13
|
+
const [key, value] = part.split("=");
|
|
14
|
+
if (key && value) {
|
|
15
|
+
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
16
|
+
} else if (key) {
|
|
17
|
+
params.push(encodeURIComponent(key));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return params.join("&");
|
|
21
|
+
};
|
|
22
|
+
|
|
6
23
|
/**
|
|
7
24
|
*/
|
|
8
25
|
export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
@@ -15,7 +32,7 @@ export const getFullRequestUrl = (request: HttpServletRequestJava): string => {
|
|
|
15
32
|
.join("/");
|
|
16
33
|
|
|
17
34
|
if (queryString) {
|
|
18
|
-
return `${pathInfo}?${
|
|
35
|
+
return `${pathInfo}?${encodeQueryString(queryString)}`;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
return pathInfo;
|