1
1
'use strict'
2
2
3
- const corsSafeListedMethods = [ 'GET' , 'HEAD' , 'POST' ]
3
+ const corsSafeListedMethods = /** @type { const } */ ( [ 'GET' , 'HEAD' , 'POST' ] )
4
4
const corsSafeListedMethodsSet = new Set ( corsSafeListedMethods )
5
5
6
- const nullBodyStatus = [ 101 , 204 , 205 , 304 ]
6
+ const nullBodyStatus = /** @type { const } */ ( [ 101 , 204 , 205 , 304 ] )
7
7
8
- const redirectStatus = [ 301 , 302 , 303 , 307 , 308 ]
8
+ const redirectStatus = /** @type { const } */ ( [ 301 , 302 , 303 , 307 , 308 ] )
9
9
const redirectStatusSet = new Set ( redirectStatus )
10
10
11
- // https://fetch.spec.whatwg.org/#block-bad-port
12
- const badPorts = [
11
+ /**
12
+ * @see https://fetch.spec.whatwg.org/#block-bad-port
13
+ */
14
+ const badPorts = /** @type {const } */ ( [
13
15
'1' , '7' , '9' , '11' , '13' , '15' , '17' , '19' , '20' , '21' , '22' , '23' , '25' , '37' , '42' , '43' , '53' , '69' , '77' , '79' ,
14
16
'87' , '95' , '101' , '102' , '103' , '104' , '109' , '110' , '111' , '113' , '115' , '117' , '119' , '123' , '135' , '137' ,
15
17
'139' , '143' , '161' , '179' , '389' , '427' , '465' , '512' , '513' , '514' , '515' , '526' , '530' , '531' , '532' ,
16
18
'540' , '548' , '554' , '556' , '563' , '587' , '601' , '636' , '989' , '990' , '993' , '995' , '1719' , '1720' , '1723' ,
17
19
'2049' , '3659' , '4045' , '4190' , '5060' , '5061' , '6000' , '6566' , '6665' , '6666' , '6667' , '6668' , '6669' , '6679' ,
18
20
'6697' , '10080'
19
- ]
20
-
21
+ ] )
21
22
const badPortsSet = new Set ( badPorts )
22
23
23
- // https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
24
- const referrerPolicy = [
24
+ /**
25
+ * @see https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
26
+ */
27
+ const referrerPolicy = /** @type {const } */ ( [
25
28
'' ,
26
29
'no-referrer' ,
27
30
'no-referrer-when-downgrade' ,
@@ -31,29 +34,31 @@ const referrerPolicy = [
31
34
'origin-when-cross-origin' ,
32
35
'strict-origin-when-cross-origin' ,
33
36
'unsafe-url'
34
- ]
37
+ ] )
35
38
const referrerPolicySet = new Set ( referrerPolicy )
36
39
37
- const requestRedirect = [ 'follow' , 'manual' , 'error' ]
40
+ const requestRedirect = /** @type { const } */ ( [ 'follow' , 'manual' , 'error' ] )
38
41
39
- const safeMethods = [ 'GET' , 'HEAD' , 'OPTIONS' , 'TRACE' ]
42
+ const safeMethods = /** @type { const } */ ( [ 'GET' , 'HEAD' , 'OPTIONS' , 'TRACE' ] )
40
43
const safeMethodsSet = new Set ( safeMethods )
41
44
42
- const requestMode = [ 'navigate' , 'same-origin' , 'no-cors' , 'cors' ]
45
+ const requestMode = /** @type { const } */ ( [ 'navigate' , 'same-origin' , 'no-cors' , 'cors' ] )
43
46
44
- const requestCredentials = [ 'omit' , 'same-origin' , 'include' ]
47
+ const requestCredentials = /** @type { const } */ ( [ 'omit' , 'same-origin' , 'include' ] )
45
48
46
- const requestCache = [
49
+ const requestCache = /** @type { const } */ ( [
47
50
'default' ,
48
51
'no-store' ,
49
52
'reload' ,
50
53
'no-cache' ,
51
54
'force-cache' ,
52
55
'only-if-cached'
53
- ]
56
+ ] )
54
57
55
- // https://fetch.spec.whatwg.org/#request-body-header-name
56
- const requestBodyHeader = [
58
+ /**
59
+ * @see https://fetch.spec.whatwg.org/#request-body-header-name
60
+ */
61
+ const requestBodyHeader = /** @type {const } */ ( [
57
62
'content-encoding' ,
58
63
'content-language' ,
59
64
'content-location' ,
@@ -63,18 +68,22 @@ const requestBodyHeader = [
63
68
// removed in the Headers implementation. However, undici doesn't
64
69
// filter out headers, so we add it here.
65
70
'content-length'
66
- ]
71
+ ] )
67
72
68
- // https://fetch.spec.whatwg.org/#enumdef-requestduplex
69
- const requestDuplex = [
73
+ /**
74
+ * @see https://fetch.spec.whatwg.org/#enumdef-requestduplex
75
+ */
76
+ const requestDuplex = /** @type {const } */ ( [
70
77
'half'
71
- ]
78
+ ] )
72
79
73
- // http://fetch.spec.whatwg.org/#forbidden-method
74
- const forbiddenMethods = [ 'CONNECT' , 'TRACE' , 'TRACK' ]
80
+ /**
81
+ * @see http://fetch.spec.whatwg.org/#forbidden-method
82
+ */
83
+ const forbiddenMethods = /** @type {const } */ ( [ 'CONNECT' , 'TRACE' , 'TRACK' ] )
75
84
const forbiddenMethodsSet = new Set ( forbiddenMethods )
76
85
77
- const subresource = [
86
+ const subresource = /** @type { const } */ ( [
78
87
'audio' ,
79
88
'audioworklet' ,
80
89
'font' ,
@@ -87,7 +96,7 @@ const subresource = [
87
96
'video' ,
88
97
'xslt' ,
89
98
''
90
- ]
99
+ ] )
91
100
const subresourceSet = new Set ( subresource )
92
101
93
102
module . exports = {
0 commit comments