cdk-common 2.0.900 → 2.0.902

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.
Files changed (96) hide show
  1. package/.jsii +2 -2
  2. package/lib/main.js +1 -1
  3. package/node_modules/fast-uri/.gitattributes +2 -0
  4. package/node_modules/fast-uri/.github/.stale.yml +21 -0
  5. package/node_modules/fast-uri/.github/dependabot.yml +13 -0
  6. package/node_modules/fast-uri/.github/tests_checker.yml +8 -0
  7. package/node_modules/fast-uri/.github/workflows/ci.yml +23 -0
  8. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +20 -0
  9. package/node_modules/fast-uri/.taprc +3 -0
  10. package/node_modules/fast-uri/LICENSE +30 -0
  11. package/node_modules/fast-uri/README.md +125 -0
  12. package/node_modules/fast-uri/benchmark.js +105 -0
  13. package/node_modules/fast-uri/index.js +309 -0
  14. package/node_modules/fast-uri/lib/schemes.js +188 -0
  15. package/node_modules/fast-uri/lib/scopedChars.js +30 -0
  16. package/node_modules/fast-uri/lib/utils.js +242 -0
  17. package/node_modules/fast-uri/package.json +39 -0
  18. package/node_modules/fast-uri/test/.gitkeep +0 -0
  19. package/node_modules/fast-uri/test/ajv.test.js +39 -0
  20. package/node_modules/fast-uri/test/compatibility.test.js +130 -0
  21. package/node_modules/fast-uri/test/equal.test.js +104 -0
  22. package/node_modules/fast-uri/test/parse.test.js +319 -0
  23. package/node_modules/fast-uri/test/resolve.test.js +76 -0
  24. package/node_modules/fast-uri/test/serialize.test.js +144 -0
  25. package/node_modules/fast-uri/test/uri-js.test.js +940 -0
  26. package/node_modules/fast-uri/test/util.test.js +24 -0
  27. package/node_modules/fast-uri/types/index.d.ts +53 -0
  28. package/node_modules/fast-uri/types/index.test-d.ts +17 -0
  29. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js +1 -0
  30. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
  31. package/node_modules/table/node_modules/ajv/dist/compile/index.js.map +1 -1
  32. package/node_modules/table/node_modules/ajv/dist/compile/resolve.d.ts +2 -2
  33. package/node_modules/table/node_modules/ajv/dist/compile/resolve.js.map +1 -1
  34. package/node_modules/table/node_modules/ajv/dist/runtime/uri.d.ts +1 -1
  35. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js +1 -1
  36. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js.map +1 -1
  37. package/node_modules/table/node_modules/ajv/dist/types/index.d.ts +3 -3
  38. package/node_modules/table/node_modules/ajv/dist/types/json-schema.d.ts +10 -10
  39. package/node_modules/table/node_modules/ajv/lib/compile/codegen/code.ts +1 -0
  40. package/node_modules/table/node_modules/ajv/lib/compile/index.ts +2 -2
  41. package/node_modules/table/node_modules/ajv/lib/compile/resolve.ts +2 -2
  42. package/node_modules/table/node_modules/ajv/lib/runtime/uri.ts +1 -1
  43. package/node_modules/table/node_modules/ajv/lib/types/index.ts +3 -3
  44. package/node_modules/table/node_modules/ajv/lib/types/json-schema.ts +10 -10
  45. package/node_modules/table/node_modules/ajv/package.json +5 -5
  46. package/package.json +1 -1
  47. package/node_modules/punycode/LICENSE-MIT.txt +0 -20
  48. package/node_modules/punycode/README.md +0 -148
  49. package/node_modules/punycode/package.json +0 -58
  50. package/node_modules/punycode/punycode.es6.js +0 -444
  51. package/node_modules/punycode/punycode.js +0 -443
  52. package/node_modules/uri-js/LICENSE +0 -11
  53. package/node_modules/uri-js/README.md +0 -203
  54. package/node_modules/uri-js/dist/es5/uri.all.d.ts +0 -59
  55. package/node_modules/uri-js/dist/es5/uri.all.js +0 -1443
  56. package/node_modules/uri-js/dist/es5/uri.all.js.map +0 -1
  57. package/node_modules/uri-js/dist/es5/uri.all.min.d.ts +0 -59
  58. package/node_modules/uri-js/dist/es5/uri.all.min.js +0 -3
  59. package/node_modules/uri-js/dist/es5/uri.all.min.js.map +0 -1
  60. package/node_modules/uri-js/dist/esnext/index.d.ts +0 -1
  61. package/node_modules/uri-js/dist/esnext/index.js +0 -17
  62. package/node_modules/uri-js/dist/esnext/index.js.map +0 -1
  63. package/node_modules/uri-js/dist/esnext/regexps-iri.d.ts +0 -3
  64. package/node_modules/uri-js/dist/esnext/regexps-iri.js +0 -3
  65. package/node_modules/uri-js/dist/esnext/regexps-iri.js.map +0 -1
  66. package/node_modules/uri-js/dist/esnext/regexps-uri.d.ts +0 -4
  67. package/node_modules/uri-js/dist/esnext/regexps-uri.js +0 -42
  68. package/node_modules/uri-js/dist/esnext/regexps-uri.js.map +0 -1
  69. package/node_modules/uri-js/dist/esnext/schemes/http.d.ts +0 -3
  70. package/node_modules/uri-js/dist/esnext/schemes/http.js +0 -28
  71. package/node_modules/uri-js/dist/esnext/schemes/http.js.map +0 -1
  72. package/node_modules/uri-js/dist/esnext/schemes/https.d.ts +0 -3
  73. package/node_modules/uri-js/dist/esnext/schemes/https.js +0 -9
  74. package/node_modules/uri-js/dist/esnext/schemes/https.js.map +0 -1
  75. package/node_modules/uri-js/dist/esnext/schemes/mailto.d.ts +0 -12
  76. package/node_modules/uri-js/dist/esnext/schemes/mailto.js +0 -148
  77. package/node_modules/uri-js/dist/esnext/schemes/mailto.js.map +0 -1
  78. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.d.ts +0 -7
  79. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js +0 -23
  80. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js.map +0 -1
  81. package/node_modules/uri-js/dist/esnext/schemes/urn.d.ts +0 -10
  82. package/node_modules/uri-js/dist/esnext/schemes/urn.js +0 -49
  83. package/node_modules/uri-js/dist/esnext/schemes/urn.js.map +0 -1
  84. package/node_modules/uri-js/dist/esnext/schemes/ws.d.ts +0 -7
  85. package/node_modules/uri-js/dist/esnext/schemes/ws.js +0 -41
  86. package/node_modules/uri-js/dist/esnext/schemes/ws.js.map +0 -1
  87. package/node_modules/uri-js/dist/esnext/schemes/wss.d.ts +0 -3
  88. package/node_modules/uri-js/dist/esnext/schemes/wss.js +0 -9
  89. package/node_modules/uri-js/dist/esnext/schemes/wss.js.map +0 -1
  90. package/node_modules/uri-js/dist/esnext/uri.d.ts +0 -59
  91. package/node_modules/uri-js/dist/esnext/uri.js +0 -480
  92. package/node_modules/uri-js/dist/esnext/uri.js.map +0 -1
  93. package/node_modules/uri-js/dist/esnext/util.d.ts +0 -6
  94. package/node_modules/uri-js/dist/esnext/util.js +0 -36
  95. package/node_modules/uri-js/dist/esnext/util.js.map +0 -1
  96. package/node_modules/uri-js/package.json +0 -77
@@ -0,0 +1,319 @@
1
+ 'use strict'
2
+
3
+ const tap = require('tap')
4
+ const test = tap.test
5
+ const URI = require('../')
6
+
7
+ test('URI parse', (t) => {
8
+ let components
9
+
10
+ // scheme
11
+ components = URI.parse('uri:')
12
+ t.equal(components.error, undefined, 'scheme errors')
13
+ t.equal(components.scheme, 'uri', 'scheme')
14
+ // t.equal(components.authority, undefined, "authority");
15
+ t.equal(components.userinfo, undefined, 'userinfo')
16
+ t.equal(components.host, undefined, 'host')
17
+ t.equal(components.port, undefined, 'port')
18
+ t.equal(components.path, '', 'path')
19
+ t.equal(components.query, undefined, 'query')
20
+ t.equal(components.fragment, undefined, 'fragment')
21
+
22
+ // userinfo
23
+ components = URI.parse('//@')
24
+ t.equal(components.error, undefined, 'userinfo errors')
25
+ t.equal(components.scheme, undefined, 'scheme')
26
+ // t.equal(components.authority, "@", "authority");
27
+ t.equal(components.userinfo, '', 'userinfo')
28
+ t.equal(components.host, '', 'host')
29
+ t.equal(components.port, undefined, 'port')
30
+ t.equal(components.path, '', 'path')
31
+ t.equal(components.query, undefined, 'query')
32
+ t.equal(components.fragment, undefined, 'fragment')
33
+
34
+ // host
35
+ components = URI.parse('//')
36
+ t.equal(components.error, undefined, 'host errors')
37
+ t.equal(components.scheme, undefined, 'scheme')
38
+ // t.equal(components.authority, "", "authority");
39
+ t.equal(components.userinfo, undefined, 'userinfo')
40
+ t.equal(components.host, '', 'host')
41
+ t.equal(components.port, undefined, 'port')
42
+ t.equal(components.path, '', 'path')
43
+ t.equal(components.query, undefined, 'query')
44
+ t.equal(components.fragment, undefined, 'fragment')
45
+
46
+ // port
47
+ components = URI.parse('//:')
48
+ t.equal(components.error, undefined, 'port errors')
49
+ t.equal(components.scheme, undefined, 'scheme')
50
+ // t.equal(components.authority, ":", "authority");
51
+ t.equal(components.userinfo, undefined, 'userinfo')
52
+ t.equal(components.host, '', 'host')
53
+ t.equal(components.port, '', 'port')
54
+ t.equal(components.path, '', 'path')
55
+ t.equal(components.query, undefined, 'query')
56
+ t.equal(components.fragment, undefined, 'fragment')
57
+
58
+ // path
59
+ components = URI.parse('')
60
+ t.equal(components.error, undefined, 'path errors')
61
+ t.equal(components.scheme, undefined, 'scheme')
62
+ // t.equal(components.authority, undefined, "authority");
63
+ t.equal(components.userinfo, undefined, 'userinfo')
64
+ t.equal(components.host, undefined, 'host')
65
+ t.equal(components.port, undefined, 'port')
66
+ t.equal(components.path, '', 'path')
67
+ t.equal(components.query, undefined, 'query')
68
+ t.equal(components.fragment, undefined, 'fragment')
69
+
70
+ // query
71
+ components = URI.parse('?')
72
+ t.equal(components.error, undefined, 'query errors')
73
+ t.equal(components.scheme, undefined, 'scheme')
74
+ // t.equal(components.authority, undefined, "authority");
75
+ t.equal(components.userinfo, undefined, 'userinfo')
76
+ t.equal(components.host, undefined, 'host')
77
+ t.equal(components.port, undefined, 'port')
78
+ t.equal(components.path, '', 'path')
79
+ t.equal(components.query, '', 'query')
80
+ t.equal(components.fragment, undefined, 'fragment')
81
+
82
+ // fragment
83
+ components = URI.parse('#')
84
+ t.equal(components.error, undefined, 'fragment errors')
85
+ t.equal(components.scheme, undefined, 'scheme')
86
+ // t.equal(components.authority, undefined, "authority");
87
+ t.equal(components.userinfo, undefined, 'userinfo')
88
+ t.equal(components.host, undefined, 'host')
89
+ t.equal(components.port, undefined, 'port')
90
+ t.equal(components.path, '', 'path')
91
+ t.equal(components.query, undefined, 'query')
92
+ t.equal(components.fragment, '', 'fragment')
93
+
94
+ // fragment with character tabulation
95
+ components = URI.parse('#\t')
96
+ t.equal(components.error, undefined, 'path errors')
97
+ t.equal(components.scheme, undefined, 'scheme')
98
+ // t.equal(components.authority, undefined, "authority");
99
+ t.equal(components.userinfo, undefined, 'userinfo')
100
+ t.equal(components.host, undefined, 'host')
101
+ t.equal(components.port, undefined, 'port')
102
+ t.equal(components.path, '', 'path')
103
+ t.equal(components.query, undefined, 'query')
104
+ t.equal(components.fragment, '%09', 'fragment')
105
+
106
+ // fragment with line feed
107
+ components = URI.parse('#\n')
108
+ t.equal(components.error, undefined, 'path errors')
109
+ t.equal(components.scheme, undefined, 'scheme')
110
+ // t.equal(components.authority, undefined, "authority");
111
+ t.equal(components.userinfo, undefined, 'userinfo')
112
+ t.equal(components.host, undefined, 'host')
113
+ t.equal(components.port, undefined, 'port')
114
+ t.equal(components.path, '', 'path')
115
+ t.equal(components.query, undefined, 'query')
116
+ t.equal(components.fragment, '%0A', 'fragment')
117
+
118
+ // fragment with line tabulation
119
+ components = URI.parse('#\v')
120
+ t.equal(components.error, undefined, 'path errors')
121
+ t.equal(components.scheme, undefined, 'scheme')
122
+ // t.equal(components.authority, undefined, "authority");
123
+ t.equal(components.userinfo, undefined, 'userinfo')
124
+ t.equal(components.host, undefined, 'host')
125
+ t.equal(components.port, undefined, 'port')
126
+ t.equal(components.path, '', 'path')
127
+ t.equal(components.query, undefined, 'query')
128
+ t.equal(components.fragment, '%0B', 'fragment')
129
+
130
+ // fragment with form feed
131
+ components = URI.parse('#\f')
132
+ t.equal(components.error, undefined, 'path errors')
133
+ t.equal(components.scheme, undefined, 'scheme')
134
+ // t.equal(components.authority, undefined, "authority");
135
+ t.equal(components.userinfo, undefined, 'userinfo')
136
+ t.equal(components.host, undefined, 'host')
137
+ t.equal(components.port, undefined, 'port')
138
+ t.equal(components.path, '', 'path')
139
+ t.equal(components.query, undefined, 'query')
140
+ t.equal(components.fragment, '%0C', 'fragment')
141
+
142
+ // fragment with carriage return
143
+ components = URI.parse('#\r')
144
+ t.equal(components.error, undefined, 'path errors')
145
+ t.equal(components.scheme, undefined, 'scheme')
146
+ // t.equal(components.authority, undefined, "authority");
147
+ t.equal(components.userinfo, undefined, 'userinfo')
148
+ t.equal(components.host, undefined, 'host')
149
+ t.equal(components.port, undefined, 'port')
150
+ t.equal(components.path, '', 'path')
151
+ t.equal(components.query, undefined, 'query')
152
+ t.equal(components.fragment, '%0D', 'fragment')
153
+
154
+ // all
155
+ components = URI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
156
+ t.equal(components.error, undefined, 'all errors')
157
+ t.equal(components.scheme, 'uri', 'scheme')
158
+ // t.equal(components.authority, "user:pass@example.com:123", "authority");
159
+ t.equal(components.userinfo, 'user:pass', 'userinfo')
160
+ t.equal(components.host, 'example.com', 'host')
161
+ t.equal(components.port, 123, 'port')
162
+ t.equal(components.path, '/one/two.three', 'path')
163
+ t.equal(components.query, 'q1=a1&q2=a2', 'query')
164
+ t.equal(components.fragment, 'body', 'fragment')
165
+
166
+ // IPv4address
167
+ components = URI.parse('//10.10.10.10')
168
+ t.equal(components.error, undefined, 'IPv4address errors')
169
+ t.equal(components.scheme, undefined, 'scheme')
170
+ t.equal(components.userinfo, undefined, 'userinfo')
171
+ t.equal(components.host, '10.10.10.10', 'host')
172
+ t.equal(components.port, undefined, 'port')
173
+ t.equal(components.path, '', 'path')
174
+ t.equal(components.query, undefined, 'query')
175
+ t.equal(components.fragment, undefined, 'fragment')
176
+
177
+ // IPv4address with unformated 0 stay as-is
178
+ components = URI.parse('//10.10.000.10') // not valid as per https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
179
+ t.equal(components.error, undefined, 'IPv4address errors')
180
+ t.equal(components.scheme, undefined, 'scheme')
181
+ t.equal(components.userinfo, undefined, 'userinfo')
182
+ t.equal(components.host, '10.10.000.10', 'host')
183
+ t.equal(components.port, undefined, 'port')
184
+ t.equal(components.path, '', 'path')
185
+ t.equal(components.query, undefined, 'query')
186
+ t.equal(components.fragment, undefined, 'fragment')
187
+ components = URI.parse('//01.01.01.01') // not valid in URIs: https://datatracker.ietf.org/doc/html/rfc3986#section-7.4
188
+ t.equal(components.error, undefined, 'IPv4address errors')
189
+ t.equal(components.scheme, undefined, 'scheme')
190
+ t.equal(components.userinfo, undefined, 'userinfo')
191
+ t.equal(components.host, '01.01.01.01', 'host')
192
+ t.equal(components.port, undefined, 'port')
193
+ t.equal(components.path, '', 'path')
194
+ t.equal(components.query, undefined, 'query')
195
+ t.equal(components.fragment, undefined, 'fragment')
196
+
197
+ // IPv6address
198
+ components = URI.parse('//[2001:db8::7]')
199
+ t.equal(components.error, undefined, 'IPv4address errors')
200
+ t.equal(components.scheme, undefined, 'scheme')
201
+ t.equal(components.userinfo, undefined, 'userinfo')
202
+ t.equal(components.host, '2001:db8::7', 'host')
203
+ t.equal(components.port, undefined, 'port')
204
+ t.equal(components.path, '', 'path')
205
+ t.equal(components.query, undefined, 'query')
206
+ t.equal(components.fragment, undefined, 'fragment')
207
+
208
+ // invalid IPv6
209
+ components = URI.parse('//[2001:dbZ::7]')
210
+ t.equal(components.host, '[2001:dbz::7]')
211
+
212
+ // mixed IPv4address & IPv6address
213
+ components = URI.parse('//[::ffff:129.144.52.38]')
214
+ t.equal(components.error, undefined, 'IPv4address errors')
215
+ t.equal(components.scheme, undefined, 'scheme')
216
+ t.equal(components.userinfo, undefined, 'userinfo')
217
+ t.equal(components.host, '::ffff:129.144.52.38', 'host')
218
+ t.equal(components.port, undefined, 'port')
219
+ t.equal(components.path, '', 'path')
220
+ t.equal(components.query, undefined, 'query')
221
+ t.equal(components.fragment, undefined, 'fragment')
222
+
223
+ // mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
224
+ components = URI.parse('uri://10.10.10.10.example.com/en/process')
225
+ t.equal(components.error, undefined, 'mixed errors')
226
+ t.equal(components.scheme, 'uri', 'scheme')
227
+ t.equal(components.userinfo, undefined, 'userinfo')
228
+ t.equal(components.host, '10.10.10.10.example.com', 'host')
229
+ t.equal(components.port, undefined, 'port')
230
+ t.equal(components.path, '/en/process', 'path')
231
+ t.equal(components.query, undefined, 'query')
232
+ t.equal(components.fragment, undefined, 'fragment')
233
+
234
+ // IPv6address, example from bkw (https://github.com/garycourt/uri-js/pull/16)
235
+ components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946]/test')
236
+ t.equal(components.error, undefined, 'IPv6address errors')
237
+ t.equal(components.scheme, undefined, 'scheme')
238
+ t.equal(components.userinfo, undefined, 'userinfo')
239
+ t.equal(components.host, '2606:2800:220:1:248:1893:25c8:1946', 'host')
240
+ t.equal(components.port, undefined, 'port')
241
+ t.equal(components.path, '/test', 'path')
242
+ t.equal(components.query, undefined, 'query')
243
+ t.equal(components.fragment, undefined, 'fragment')
244
+
245
+ // IPv6address, example from RFC 5952
246
+ components = URI.parse('//[2001:db8::1]:80')
247
+ t.equal(components.error, undefined, 'IPv6address errors')
248
+ t.equal(components.scheme, undefined, 'scheme')
249
+ t.equal(components.userinfo, undefined, 'userinfo')
250
+ t.equal(components.host, '2001:db8::1', 'host')
251
+ t.equal(components.port, 80, 'port')
252
+ t.equal(components.path, '', 'path')
253
+ t.equal(components.query, undefined, 'query')
254
+ t.equal(components.fragment, undefined, 'fragment')
255
+
256
+ // IPv6address with zone identifier, RFC 6874
257
+ components = URI.parse('//[fe80::a%25en1]')
258
+ t.equal(components.error, undefined, 'IPv4address errors')
259
+ t.equal(components.scheme, undefined, 'scheme')
260
+ t.equal(components.userinfo, undefined, 'userinfo')
261
+ t.equal(components.host, 'fe80::a%en1', 'host')
262
+ t.equal(components.port, undefined, 'port')
263
+ t.equal(components.path, '', 'path')
264
+ t.equal(components.query, undefined, 'query')
265
+ t.equal(components.fragment, undefined, 'fragment')
266
+
267
+ // IPv6address with an unescaped interface specifier, example from pekkanikander (https://github.com/garycourt/uri-js/pull/22)
268
+ components = URI.parse('//[2001:db8::7%en0]')
269
+ t.equal(components.error, undefined, 'IPv6address interface errors')
270
+ t.equal(components.scheme, undefined, 'scheme')
271
+ t.equal(components.userinfo, undefined, 'userinfo')
272
+ t.equal(components.host, '2001:db8::7%en0', 'host')
273
+ t.equal(components.port, undefined, 'port')
274
+ t.equal(components.path, '', 'path')
275
+ t.equal(components.query, undefined, 'query')
276
+ t.equal(components.fragment, undefined, 'fragment')
277
+
278
+ // UUID V1
279
+ components = URI.parse('urn:uuid:b571b0bc-4713-11ec-81d3-0242ac130003')
280
+ t.equal(components.error, undefined, 'errors')
281
+ t.equal(components.scheme, 'urn', 'scheme')
282
+ // t.equal(components.authority, undefined, "authority");
283
+ t.equal(components.userinfo, undefined, 'userinfo')
284
+ t.equal(components.host, undefined, 'host')
285
+ t.equal(components.port, undefined, 'port')
286
+ t.equal(components.path, undefined, 'path')
287
+ t.equal(components.query, undefined, 'query')
288
+ t.equal(components.fragment, undefined, 'fragment')
289
+ t.equal(components.nid, 'uuid', 'nid')
290
+ t.equal(components.nss, undefined, 'nss')
291
+ t.equal(components.uuid, 'b571b0bc-4713-11ec-81d3-0242ac130003', 'uuid')
292
+
293
+ // UUID v4
294
+ components = URI.parse('urn:uuid:97a32222-89b7-420e-8507-4360723e2c2a')
295
+ t.equal(components.uuid, '97a32222-89b7-420e-8507-4360723e2c2a', 'uuid')
296
+
297
+ components = URI.parse('urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
298
+ t.notSame(components.error, undefined, 'errors')
299
+
300
+ components = URI.parse('urn:foo:a123,456')
301
+ t.equal(components.error, undefined, 'errors')
302
+ t.equal(components.scheme, 'urn', 'scheme')
303
+ // t.equal(components.authority, undefined, "authority");
304
+ t.equal(components.userinfo, undefined, 'userinfo')
305
+ t.equal(components.host, undefined, 'host')
306
+ t.equal(components.port, undefined, 'port')
307
+ t.equal(components.path, undefined, 'path')
308
+ t.equal(components.query, undefined, 'query')
309
+ t.equal(components.fragment, undefined, 'fragment')
310
+ t.equal(components.nid, 'foo', 'nid')
311
+ t.equal(components.nss, 'a123,456', 'nss')
312
+
313
+ components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946:43209]')
314
+ t.equal(components.host, '[2606:2800:220:1:248:1893:25c8:1946:43209]')
315
+
316
+ components = URI.parse('urn:foo:|\\24fpl')
317
+ t.equal(components.error, 'URN can not be parsed.')
318
+ t.end()
319
+ })
@@ -0,0 +1,76 @@
1
+ 'use strict'
2
+
3
+ const tap = require('tap')
4
+ const test = tap.test
5
+ const URI = require('../')
6
+
7
+ test('URI Resolving', (t) => {
8
+ // normal examples from RFC 3986
9
+ const base = 'uri://a/b/c/d;p?q'
10
+ t.equal(URI.resolve(base, 'g:h'), 'g:h', 'g:h')
11
+ t.equal(URI.resolve(base, 'g:h'), 'g:h', 'g:h')
12
+ t.equal(URI.resolve(base, 'g'), 'uri://a/b/c/g', 'g')
13
+ t.equal(URI.resolve(base, './g'), 'uri://a/b/c/g', './g')
14
+ t.equal(URI.resolve(base, 'g/'), 'uri://a/b/c/g/', 'g/')
15
+ t.equal(URI.resolve(base, '/g'), 'uri://a/g', '/g')
16
+ t.equal(URI.resolve(base, '//g'), 'uri://g', '//g')
17
+ t.equal(URI.resolve(base, '?y'), 'uri://a/b/c/d;p?y', '?y')
18
+ t.equal(URI.resolve(base, 'g?y'), 'uri://a/b/c/g?y', 'g?y')
19
+ t.equal(URI.resolve(base, '#s'), 'uri://a/b/c/d;p?q#s', '#s')
20
+ t.equal(URI.resolve(base, 'g#s'), 'uri://a/b/c/g#s', 'g#s')
21
+ t.equal(URI.resolve(base, 'g?y#s'), 'uri://a/b/c/g?y#s', 'g?y#s')
22
+ t.equal(URI.resolve(base, ';x'), 'uri://a/b/c/;x', ';x')
23
+ t.equal(URI.resolve(base, 'g;x'), 'uri://a/b/c/g;x', 'g;x')
24
+ t.equal(URI.resolve(base, 'g;x?y#s'), 'uri://a/b/c/g;x?y#s', 'g;x?y#s')
25
+ t.equal(URI.resolve(base, ''), 'uri://a/b/c/d;p?q', '')
26
+ t.equal(URI.resolve(base, '.'), 'uri://a/b/c/', '.')
27
+ t.equal(URI.resolve(base, './'), 'uri://a/b/c/', './')
28
+ t.equal(URI.resolve(base, '..'), 'uri://a/b/', '..')
29
+ t.equal(URI.resolve(base, '../'), 'uri://a/b/', '../')
30
+ t.equal(URI.resolve(base, '../g'), 'uri://a/b/g', '../g')
31
+ t.equal(URI.resolve(base, '../..'), 'uri://a/', '../..')
32
+ t.equal(URI.resolve(base, '../../'), 'uri://a/', '../../')
33
+ t.equal(URI.resolve(base, '../../g'), 'uri://a/g', '../../g')
34
+
35
+ // abnormal examples from RFC 3986
36
+ t.equal(URI.resolve(base, '../../../g'), 'uri://a/g', '../../../g')
37
+ t.equal(URI.resolve(base, '../../../../g'), 'uri://a/g', '../../../../g')
38
+
39
+ t.equal(URI.resolve(base, '/./g'), 'uri://a/g', '/./g')
40
+ t.equal(URI.resolve(base, '/../g'), 'uri://a/g', '/../g')
41
+ t.equal(URI.resolve(base, 'g.'), 'uri://a/b/c/g.', 'g.')
42
+ t.equal(URI.resolve(base, '.g'), 'uri://a/b/c/.g', '.g')
43
+ t.equal(URI.resolve(base, 'g..'), 'uri://a/b/c/g..', 'g..')
44
+ t.equal(URI.resolve(base, '..g'), 'uri://a/b/c/..g', '..g')
45
+
46
+ t.equal(URI.resolve(base, './../g'), 'uri://a/b/g', './../g')
47
+ t.equal(URI.resolve(base, './g/.'), 'uri://a/b/c/g/', './g/.')
48
+ t.equal(URI.resolve(base, 'g/./h'), 'uri://a/b/c/g/h', 'g/./h')
49
+ t.equal(URI.resolve(base, 'g/../h'), 'uri://a/b/c/h', 'g/../h')
50
+ t.equal(URI.resolve(base, 'g;x=1/./y'), 'uri://a/b/c/g;x=1/y', 'g;x=1/./y')
51
+ t.equal(URI.resolve(base, 'g;x=1/../y'), 'uri://a/b/c/y', 'g;x=1/../y')
52
+
53
+ t.equal(URI.resolve(base, 'g?y/./x'), 'uri://a/b/c/g?y/./x', 'g?y/./x')
54
+ t.equal(URI.resolve(base, 'g?y/../x'), 'uri://a/b/c/g?y/../x', 'g?y/../x')
55
+ t.equal(URI.resolve(base, 'g#s/./x'), 'uri://a/b/c/g#s/./x', 'g#s/./x')
56
+ t.equal(URI.resolve(base, 'g#s/../x'), 'uri://a/b/c/g#s/../x', 'g#s/../x')
57
+
58
+ t.equal(URI.resolve(base, 'uri:g'), 'uri:g', 'uri:g')
59
+ t.equal(URI.resolve(base, 'uri:g', { tolerant: true }), 'uri://a/b/c/g', 'uri:g')
60
+
61
+ // examples by PAEz
62
+ // example was provided to avoid infinite loop within regex
63
+ // this is not the case anymore
64
+ // t.equal(URI.resolve('//www.g.com/', '/adf\ngf'), '//www.g.com/adf%0Agf', '/adf\\ngf')
65
+ // t.equal(URI.resolve('//www.g.com/error\n/bleh/bleh', '..'), '//www.g.com/error%0A/', '//www.g.com/error\\n/bleh/bleh')
66
+ t.end()
67
+ })
68
+
69
+ test('URN Resolving', (t) => {
70
+ // example from epoberezkin
71
+ t.equal(URI.resolve('', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
72
+ t.equal(URI.resolve('#', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
73
+ t.equal(URI.resolve('urn:some:ip:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
74
+ t.equal(URI.resolve('urn:some:other:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
75
+ t.end()
76
+ })
@@ -0,0 +1,144 @@
1
+ 'use strict'
2
+
3
+ const tap = require('tap')
4
+ const test = tap.test
5
+ const URI = require('../')
6
+
7
+ test('URI Serialize', (t) => {
8
+ let components = {
9
+ scheme: undefined,
10
+ userinfo: undefined,
11
+ host: undefined,
12
+ port: undefined,
13
+ path: undefined,
14
+ query: undefined,
15
+ fragment: undefined
16
+ }
17
+ t.equal(URI.serialize(components), '', 'Undefined Components')
18
+
19
+ components = {
20
+ scheme: '',
21
+ userinfo: '',
22
+ host: '',
23
+ port: 0,
24
+ path: '',
25
+ query: '',
26
+ fragment: ''
27
+ }
28
+ t.equal(URI.serialize(components), '//@:0?#', 'Empty Components')
29
+
30
+ components = {
31
+ scheme: 'uri',
32
+ userinfo: 'foo:bar',
33
+ host: 'example.com',
34
+ port: 1,
35
+ path: 'path',
36
+ query: 'query',
37
+ fragment: 'fragment'
38
+ }
39
+ t.equal(URI.serialize(components), 'uri://foo:bar@example.com:1/path?query#fragment', 'All Components')
40
+
41
+ components = {
42
+ scheme: 'uri',
43
+ host: 'example.com',
44
+ port: '9000'
45
+ }
46
+ t.equal(URI.serialize(components), 'uri://example.com:9000', 'String port')
47
+
48
+ t.equal(URI.serialize({ path: '//path' }), '/%2Fpath', 'Double slash path')
49
+ t.equal(URI.serialize({ path: 'foo:bar' }), 'foo%3Abar', 'Colon path')
50
+ t.equal(URI.serialize({ path: '?query' }), '%3Fquery', 'Query path')
51
+
52
+ t.equal(URI.serialize({ host: '10.10.10.10' }), '//10.10.10.10', 'IPv4address')
53
+
54
+ // mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
55
+ t.equal(URI.serialize({ host: '10.10.10.10.example.com' }), '//10.10.10.10.example.com', 'Mixed IPv4address & reg-name')
56
+
57
+ // IPv6address
58
+ t.equal(URI.serialize({ host: '2001:db8::7' }), '//[2001:db8::7]', 'IPv6 Host')
59
+ t.equal(URI.serialize({ host: '::ffff:129.144.52.38' }), '//[::ffff:129.144.52.38]', 'IPv6 Mixed Host')
60
+ t.equal(URI.serialize({ host: '2606:2800:220:1:248:1893:25c8:1946' }), '//[2606:2800:220:1:248:1893:25c8:1946]', 'IPv6 Full Host')
61
+
62
+ // IPv6address with zone identifier, RFC 6874
63
+ t.equal(URI.serialize({ host: 'fe80::a%en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Unescaped Host')
64
+ t.equal(URI.serialize({ host: 'fe80::a%25en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Escaped Host')
65
+
66
+ t.end()
67
+ })
68
+
69
+ test('WS serialize', (t) => {
70
+ t.equal(URI.serialize({ scheme: 'ws' }), 'ws:')
71
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com' }), 'ws://example.com')
72
+ t.equal(URI.serialize({ scheme: 'ws', resourceName: '/' }), 'ws:')
73
+ t.equal(URI.serialize({ scheme: 'ws', resourceName: '/foo' }), 'ws:/foo')
74
+ t.equal(URI.serialize({ scheme: 'ws', resourceName: '/foo?bar' }), 'ws:/foo?bar')
75
+ t.equal(URI.serialize({ scheme: 'ws', secure: false }), 'ws:')
76
+ t.equal(URI.serialize({ scheme: 'ws', secure: true }), 'wss:')
77
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo' }), 'ws://example.com/foo')
78
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar' }), 'ws://example.com/foo?bar')
79
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', secure: false }), 'ws://example.com')
80
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', secure: true }), 'wss://example.com')
81
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
82
+ t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
83
+ t.end()
84
+ })
85
+
86
+ test('WSS serialize', (t) => {
87
+ t.equal(URI.serialize({ scheme: 'wss' }), 'wss:')
88
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com' }), 'wss://example.com')
89
+ t.equal(URI.serialize({ scheme: 'wss', resourceName: '/' }), 'wss:')
90
+ t.equal(URI.serialize({ scheme: 'wss', resourceName: '/foo' }), 'wss:/foo')
91
+ t.equal(URI.serialize({ scheme: 'wss', resourceName: '/foo?bar' }), 'wss:/foo?bar')
92
+ t.equal(URI.serialize({ scheme: 'wss', secure: false }), 'ws:')
93
+ t.equal(URI.serialize({ scheme: 'wss', secure: true }), 'wss:')
94
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo' }), 'wss://example.com/foo')
95
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar' }), 'wss://example.com/foo?bar')
96
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', secure: false }), 'ws://example.com')
97
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', secure: true }), 'wss://example.com')
98
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
99
+ t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
100
+
101
+ t.end()
102
+ })
103
+
104
+ test('URN serialize', (t) => {
105
+ // example from RFC 2141
106
+ const components = {
107
+ scheme: 'urn',
108
+ nid: 'foo',
109
+ nss: 'a123,456'
110
+ }
111
+ t.equal(URI.serialize(components), 'urn:foo:a123,456')
112
+ // example from RFC 4122
113
+ let uuidcomponents = {
114
+ scheme: 'urn',
115
+ nid: 'uuid',
116
+ uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
117
+ }
118
+ t.equal(URI.serialize(uuidcomponents), 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
119
+
120
+ uuidcomponents = {
121
+ scheme: 'urn',
122
+ nid: 'uuid',
123
+ uuid: 'notauuid-7dec-11d0-a765-00a0c91e6bf6'
124
+ }
125
+ t.equal(URI.serialize(uuidcomponents), 'urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
126
+ t.end()
127
+ })
128
+ test('URN NID Override', (t) => {
129
+ let components = URI.parse('urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6', { nid: 'uuid' })
130
+ t.equal(components.error, undefined, 'errors')
131
+ t.equal(components.scheme, 'urn', 'scheme')
132
+ t.equal(components.path, undefined, 'path')
133
+ t.equal(components.nid, 'foo', 'nid')
134
+ t.equal(components.nss, undefined, 'nss')
135
+ t.equal(components.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'uuid')
136
+
137
+ components = {
138
+ scheme: 'urn',
139
+ nid: 'foo',
140
+ uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
141
+ }
142
+ t.equal(URI.serialize(components, { nid: 'uuid' }), 'urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
143
+ t.end()
144
+ })