@verdaccio/url 11.0.0-6-next.16 → 11.0.0-6-next.18
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 +26 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +5 -24
- package/build/index.js.map +1 -1
- package/package.json +3 -3
- package/tests/getPublicUrl.spec.ts +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-6-next.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
8
|
+
|
|
9
|
+
## 11.0.0-6-next.17
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 4b29d715: chore: move improvements from v5 to v6
|
|
14
|
+
|
|
15
|
+
Migrate improvements form v5 to v6:
|
|
16
|
+
|
|
17
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
18
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
19
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
20
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
21
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
22
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [4b29d715]
|
|
27
|
+
- @verdaccio/core@6.0.0-6-next.51
|
|
28
|
+
|
|
3
29
|
## 11.0.0-6-next.16
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/build/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function wrapPrefix(prefix: string | void): string;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function combineBaseUrl(protocol: string, host: string, prefix?: string): string;
|
|
17
17
|
export declare function validateURL(publicUrl: string | void): boolean;
|
|
18
|
-
export
|
|
18
|
+
export type RequestOptions = {
|
|
19
19
|
/**
|
|
20
20
|
* Request host.
|
|
21
21
|
*/
|
package/build/index.js
CHANGED
|
@@ -10,28 +10,21 @@ exports.isHost = isHost;
|
|
|
10
10
|
exports.isURLhasValidProtocol = isURLhasValidProtocol;
|
|
11
11
|
exports.validateURL = validateURL;
|
|
12
12
|
exports.wrapPrefix = wrapPrefix;
|
|
13
|
-
|
|
14
13
|
var _debug = _interopRequireDefault(require("debug"));
|
|
15
|
-
|
|
16
14
|
var _url = require("url");
|
|
17
|
-
|
|
18
15
|
var _isURL = _interopRequireDefault(require("validator/lib/isURL"));
|
|
19
|
-
|
|
20
16
|
var _core = require("@verdaccio/core");
|
|
21
|
-
|
|
22
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
18
|
const debug = (0, _debug.default)('verdaccio:core:url');
|
|
25
19
|
const validProtocols = ['https', 'http'];
|
|
20
|
+
|
|
26
21
|
/**
|
|
27
22
|
* Check if URI is starting with "http://", "https://" or "//"
|
|
28
23
|
* @param {string} uri
|
|
29
24
|
*/
|
|
30
|
-
|
|
31
25
|
function isURLhasValidProtocol(uri) {
|
|
32
26
|
return /^(https?:)?\/\//.test(uri);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function isHost(url = '', options = {}) {
|
|
36
29
|
return (0, _isURL.default)(url, {
|
|
37
30
|
require_host: true,
|
|
@@ -43,15 +36,14 @@ function isHost(url = '', options = {}) {
|
|
|
43
36
|
...options
|
|
44
37
|
});
|
|
45
38
|
}
|
|
39
|
+
|
|
46
40
|
/**
|
|
47
41
|
* Detect running protocol (http or https)
|
|
48
42
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
43
|
function getWebProtocol(headerProtocol, protocol) {
|
|
52
44
|
let returnProtocol;
|
|
53
|
-
const [, defaultProtocol] = validProtocols;
|
|
54
|
-
|
|
45
|
+
const [, defaultProtocol] = validProtocols;
|
|
46
|
+
// HAProxy variant might return http,http with X-Forwarded-Proto
|
|
55
47
|
if (typeof headerProtocol === 'string' && headerProtocol !== '') {
|
|
56
48
|
debug('header protocol: %o', protocol);
|
|
57
49
|
const commaIndex = headerProtocol.indexOf(',');
|
|
@@ -60,10 +52,8 @@ function getWebProtocol(headerProtocol, protocol) {
|
|
|
60
52
|
debug('req protocol: %o', headerProtocol);
|
|
61
53
|
returnProtocol = protocol;
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
function wrapPrefix(prefix) {
|
|
68
58
|
if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {
|
|
69
59
|
return '';
|
|
@@ -77,12 +67,11 @@ function wrapPrefix(prefix) {
|
|
|
77
67
|
return prefix;
|
|
78
68
|
}
|
|
79
69
|
}
|
|
70
|
+
|
|
80
71
|
/**
|
|
81
72
|
* Create base url for registry.
|
|
82
73
|
* @return {String} base registry url
|
|
83
74
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
75
|
function combineBaseUrl(protocol, host, prefix = '') {
|
|
87
76
|
debug('combined protocol %o', protocol);
|
|
88
77
|
debug('combined host %o', host);
|
|
@@ -93,22 +82,18 @@ function combineBaseUrl(protocol, host, prefix = '') {
|
|
|
93
82
|
debug('combined url %o', result);
|
|
94
83
|
return result;
|
|
95
84
|
}
|
|
96
|
-
|
|
97
85
|
function validateURL(publicUrl) {
|
|
98
86
|
try {
|
|
99
87
|
const parsed = new _url.URL(publicUrl);
|
|
100
|
-
|
|
101
88
|
if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {
|
|
102
89
|
throw Error('invalid protocol');
|
|
103
90
|
}
|
|
104
|
-
|
|
105
91
|
return true;
|
|
106
92
|
} catch (err) {
|
|
107
93
|
// TODO: add error logger here
|
|
108
94
|
return false;
|
|
109
95
|
}
|
|
110
96
|
}
|
|
111
|
-
|
|
112
97
|
function getPublicUrl(url_prefix = '', requestOptions) {
|
|
113
98
|
if (validateURL(process.env.VERDACCIO_PUBLIC_URL)) {
|
|
114
99
|
const envURL = new _url.URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL).href;
|
|
@@ -116,15 +101,11 @@ function getPublicUrl(url_prefix = '', requestOptions) {
|
|
|
116
101
|
return envURL;
|
|
117
102
|
} else if (requestOptions.headers['host']) {
|
|
118
103
|
var _process$env$VERDACCI;
|
|
119
|
-
|
|
120
104
|
const host = requestOptions.headers['host'];
|
|
121
|
-
|
|
122
105
|
if (!isHost(host)) {
|
|
123
106
|
throw new Error('invalid host');
|
|
124
107
|
}
|
|
125
|
-
|
|
126
108
|
const protoHeader = ((_process$env$VERDACCI = process.env.VERDACCIO_FORWARDED_PROTO) === null || _process$env$VERDACCI === void 0 ? void 0 : _process$env$VERDACCI.toLocaleLowerCase()) ?? _core.HEADERS.FORWARDED_PROTO.toLowerCase();
|
|
127
|
-
|
|
128
109
|
const protocol = getWebProtocol(requestOptions.headers[protoHeader], requestOptions.protocol);
|
|
129
110
|
const combinedUrl = combineBaseUrl(protocol, host, url_prefix);
|
|
130
111
|
debug('public url by request %o', combinedUrl);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["debug","buildDebug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","isURLValidator","require_host","allow_trailing_dot","require_valid_protocol","require_port","require_tld","getWebProtocol","headerProtocol","protocol","returnProtocol","defaultProtocol","commaIndex","indexOf","slice","includes","wrapPrefix","prefix","startsWith","endsWith","combineBaseUrl","host","newPrefix","groupedURI","URL","result","href","validateURL","publicUrl","parsed","replace","Error","err","getPublicUrl","url_prefix","requestOptions","process","env","VERDACCIO_PUBLIC_URL","envURL","headers","protoHeader","VERDACCIO_FORWARDED_PROTO","toLocaleLowerCase","HEADERS","FORWARDED_PROTO","toLowerCase","combinedUrl"],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'url';\nimport isURLValidator from 'validator/lib/isURL';\n\nimport { HEADERS } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:core:url');\n\nconst validProtocols = ['https', 'http'];\n\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isURLhasValidProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function isHost(url: string = '', options = {}): boolean {\n return isURLValidator(url, {\n require_host: true,\n allow_trailing_dot: false,\n require_valid_protocol: false,\n // @ts-ignore\n require_port: false,\n require_tld: false,\n ...options,\n });\n}\n\n/**\n * Detect running protocol (http or https)\n */\nexport function getWebProtocol(headerProtocol: string | void, protocol: string): string {\n let returnProtocol;\n const [, defaultProtocol] = validProtocols;\n // HAProxy variant might return http,http with X-Forwarded-Proto\n if (typeof headerProtocol === 'string' && headerProtocol !== '') {\n debug('header protocol: %o', protocol);\n const commaIndex = headerProtocol.indexOf(',');\n returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;\n } else {\n debug('req protocol: %o', headerProtocol);\n returnProtocol = protocol;\n }\n\n return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;\n}\n\nexport function wrapPrefix(prefix: string | void): string {\n if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {\n return '';\n } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {\n return `/${prefix}`;\n } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `/${prefix}/`;\n } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `${prefix}/`;\n } else {\n return prefix;\n }\n}\n\n/**\n * Create base url for registry.\n * @return {String} base registry url\n */\nexport function combineBaseUrl(protocol: string, host: string, prefix: string = ''): string {\n debug('combined protocol %o', protocol);\n debug('combined host %o', host);\n const newPrefix = wrapPrefix(prefix);\n debug('combined prefix %o', newPrefix);\n const groupedURI = new URL(wrapPrefix(prefix), `${protocol}://${host}`);\n const result = groupedURI.href;\n debug('combined url %o', result);\n return result;\n}\n\nexport function validateURL(publicUrl: string | void) {\n try {\n const parsed = new URL(publicUrl as string);\n if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {\n throw Error('invalid protocol');\n }\n return true;\n } catch (err: any) {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host.\n */\n host: string;\n /**\n * Request protocol.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: { [key: string]: string };\n remoteAddress?: string;\n /**\n * Logged username the request, usually after token verification.\n */\n username?: string;\n};\n\nexport function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {\n if (validateURL(process.env.VERDACCIO_PUBLIC_URL as string)) {\n const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL as string).href;\n debug('public url by env %o', envURL);\n return envURL;\n } else if (requestOptions.headers['host']) {\n const host = requestOptions.headers['host'];\n if (!isHost(host)) {\n throw new Error('invalid host');\n }\n const protoHeader =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const protocol = getWebProtocol(requestOptions.headers[protoHeader], requestOptions.protocol);\n const combinedUrl = combineBaseUrl(protocol, host, url_prefix);\n debug('public url by request %o', combinedUrl);\n return combinedUrl;\n } else {\n return '/';\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["debug","buildDebug","validProtocols","isURLhasValidProtocol","uri","test","isHost","url","options","isURLValidator","require_host","allow_trailing_dot","require_valid_protocol","require_port","require_tld","getWebProtocol","headerProtocol","protocol","returnProtocol","defaultProtocol","commaIndex","indexOf","slice","includes","wrapPrefix","prefix","startsWith","endsWith","combineBaseUrl","host","newPrefix","groupedURI","URL","result","href","validateURL","publicUrl","parsed","replace","Error","err","getPublicUrl","url_prefix","requestOptions","process","env","VERDACCIO_PUBLIC_URL","envURL","headers","protoHeader","VERDACCIO_FORWARDED_PROTO","toLocaleLowerCase","HEADERS","FORWARDED_PROTO","toLowerCase","combinedUrl"],"sources":["../src/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'url';\nimport isURLValidator from 'validator/lib/isURL';\n\nimport { HEADERS } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:core:url');\n\nconst validProtocols = ['https', 'http'];\n\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isURLhasValidProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function isHost(url: string = '', options = {}): boolean {\n return isURLValidator(url, {\n require_host: true,\n allow_trailing_dot: false,\n require_valid_protocol: false,\n // @ts-ignore\n require_port: false,\n require_tld: false,\n ...options,\n });\n}\n\n/**\n * Detect running protocol (http or https)\n */\nexport function getWebProtocol(headerProtocol: string | void, protocol: string): string {\n let returnProtocol;\n const [, defaultProtocol] = validProtocols;\n // HAProxy variant might return http,http with X-Forwarded-Proto\n if (typeof headerProtocol === 'string' && headerProtocol !== '') {\n debug('header protocol: %o', protocol);\n const commaIndex = headerProtocol.indexOf(',');\n returnProtocol = commaIndex > 0 ? headerProtocol.slice(0, commaIndex) : headerProtocol;\n } else {\n debug('req protocol: %o', headerProtocol);\n returnProtocol = protocol;\n }\n\n return validProtocols.includes(returnProtocol) ? returnProtocol : defaultProtocol;\n}\n\nexport function wrapPrefix(prefix: string | void): string {\n if (prefix === '' || typeof prefix === 'undefined' || prefix === null) {\n return '';\n } else if (!prefix.startsWith('/') && prefix.endsWith('/')) {\n return `/${prefix}`;\n } else if (!prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `/${prefix}/`;\n } else if (prefix.startsWith('/') && !prefix.endsWith('/')) {\n return `${prefix}/`;\n } else {\n return prefix;\n }\n}\n\n/**\n * Create base url for registry.\n * @return {String} base registry url\n */\nexport function combineBaseUrl(protocol: string, host: string, prefix: string = ''): string {\n debug('combined protocol %o', protocol);\n debug('combined host %o', host);\n const newPrefix = wrapPrefix(prefix);\n debug('combined prefix %o', newPrefix);\n const groupedURI = new URL(wrapPrefix(prefix), `${protocol}://${host}`);\n const result = groupedURI.href;\n debug('combined url %o', result);\n return result;\n}\n\nexport function validateURL(publicUrl: string | void) {\n try {\n const parsed = new URL(publicUrl as string);\n if (!validProtocols.includes(parsed.protocol.replace(':', ''))) {\n throw Error('invalid protocol');\n }\n return true;\n } catch (err: any) {\n // TODO: add error logger here\n return false;\n }\n}\n\nexport type RequestOptions = {\n /**\n * Request host.\n */\n host: string;\n /**\n * Request protocol.\n */\n protocol: string;\n /**\n * Request headers.\n */\n headers: { [key: string]: string };\n remoteAddress?: string;\n /**\n * Logged username the request, usually after token verification.\n */\n username?: string;\n};\n\nexport function getPublicUrl(url_prefix: string = '', requestOptions: RequestOptions): string {\n if (validateURL(process.env.VERDACCIO_PUBLIC_URL as string)) {\n const envURL = new URL(wrapPrefix(url_prefix), process.env.VERDACCIO_PUBLIC_URL as string).href;\n debug('public url by env %o', envURL);\n return envURL;\n } else if (requestOptions.headers['host']) {\n const host = requestOptions.headers['host'];\n if (!isHost(host)) {\n throw new Error('invalid host');\n }\n const protoHeader =\n process.env.VERDACCIO_FORWARDED_PROTO?.toLocaleLowerCase() ??\n HEADERS.FORWARDED_PROTO.toLowerCase();\n const protocol = getWebProtocol(requestOptions.headers[protoHeader], requestOptions.protocol);\n const combinedUrl = combineBaseUrl(protocol, host, url_prefix);\n debug('public url by request %o', combinedUrl);\n return combinedUrl;\n } else {\n return '/';\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AAEA;AAA0C;AAE1C,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,oBAAoB,CAAC;AAE9C,MAAMC,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;;AAExC;AACA;AACA;AACA;AACO,SAASC,qBAAqB,CAACC,GAAW,EAAW;EAC1D,OAAO,iBAAiB,C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B;IACA,OAAO,KAAK;EACd;AACF;AAsBO,SAASC,YAAY,CAACC,UAAkB,GAAG,EAAE,EAAEC,cAA8B,EAAU;EAC5F,IAAIR,WAAW,CAACS,OAAO,CAACC,GAAG,CAACC,oBAAoB,CAAW,EAAE;IAC3D,MAAMC,MAAM,GAAG,IAAIf,QAAG,CAACR,UAAU,CAACkB,UAAU,CAAC,EAAEE,OAAO,CAACC,GAAG,CAACC,oBAAoB,CAAW,CAACZ,IAAI;IAC/FlC,KAAK,CAAC,sBAAsB,EAAE+C,MAAM,CAAC;IACrC,OAAOA,MAAM;EACf,CAAC,MAAM,IAAIJ,cAAc,CAACK,OAAO,CAAC,MAAM,CAAC,EAAE;IAAA;IACzC,MAAMnB,IAAI,GAAGc,cAAc,CAACK,OAAO,CAAC,MAAM,CAAC;IAC3C,IAAI,CAAC1C,MAAM,CAACuB,IAAI,CAAC,EAAE;MACjB,MAAM,IAAIU,KAAK,CAAC,cAAc,CAAC;IACjC;IACA,MAAMU,WAAW,GACf,0BAAAL,OAAO,CAACC,GAAG,CAACK,yBAAyB,0DAArC,sBAAuCC,iBAAiB,EAAE,KAC1DC,aAAO,CAACC,eAAe,CAACC,WAAW,EAAE;IACvC,MAAMrC,QAAQ,GAAGF,cAAc,CAAC4B,cAAc,CAACK,OAAO,CAACC,WAAW,CAAC,EAAEN,cAAc,CAAC1B,QAAQ,CAAC;IAC7F,MAAMsC,WAAW,GAAG3B,cAAc,CAACX,QAAQ,EAAEY,IAAI,EAAEa,UAAU,CAAC;IAC9D1C,KAAK,CAAC,0BAA0B,EAAEuD,WAAW,CAAC;IAC9C,OAAOA,WAAW;EACpB,CAAC,MAAM;IACL,OAAO,GAAG;EACZ;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/url",
|
|
3
|
-
"version": "11.0.0-6-next.
|
|
3
|
+
"version": "11.0.0-6-next.18",
|
|
4
4
|
"description": "url utilities resolver",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"private",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
37
|
+
"@verdaccio/core": "6.0.0-6-next.52",
|
|
38
38
|
"debug": "4.3.4",
|
|
39
39
|
"lodash": "4.17.21",
|
|
40
40
|
"validator": "13.7.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@verdaccio/types": "11.0.0-6-next.17",
|
|
44
|
-
"node-mocks-http": "1.
|
|
44
|
+
"node-mocks-http": "1.12.1"
|
|
45
45
|
},
|
|
46
46
|
"funding": {
|
|
47
47
|
"type": "opencollective",
|
|
@@ -295,6 +295,27 @@ describe('env variable', () => {
|
|
|
295
295
|
delete process.env.VERDACCIO_PUBLIC_URL;
|
|
296
296
|
});
|
|
297
297
|
|
|
298
|
+
test('with the VERDACCIO_FORWARDED_PROTO undefined', () => {
|
|
299
|
+
process.env.VERDACCIO_FORWARDED_PROTO = undefined;
|
|
300
|
+
const req = httpMocks.createRequest({
|
|
301
|
+
method: 'GET',
|
|
302
|
+
headers: {
|
|
303
|
+
host: 'some.com',
|
|
304
|
+
[HEADERS.FORWARDED_PROTO]: 'https',
|
|
305
|
+
},
|
|
306
|
+
url: '/',
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
expect(
|
|
310
|
+
getPublicUrl('/test/', {
|
|
311
|
+
host: req.hostname,
|
|
312
|
+
headers: req.headers as any,
|
|
313
|
+
protocol: req.protocol,
|
|
314
|
+
})
|
|
315
|
+
).toEqual('http://some.com/test/');
|
|
316
|
+
delete process.env.VERDACCIO_FORWARDED_PROTO;
|
|
317
|
+
});
|
|
318
|
+
|
|
298
319
|
test('with a invalid X-Forwarded-Proto https and host injection with invalid host', () => {
|
|
299
320
|
process.env.VERDACCIO_PUBLIC_URL = 'http://injection.test.com"><svg onload="alert(1)">';
|
|
300
321
|
const req = httpMocks.createRequest({
|