cdk-common 2.0.1259 → 2.0.1261
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/.jsii +2 -2
- package/lib/main.js +1 -1
- package/node_modules/fast-uri/.github/workflows/ci.yml +45 -2
- package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +5 -1
- package/node_modules/fast-uri/LICENSE +3 -1
- package/node_modules/fast-uri/README.md +37 -24
- package/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
- package/node_modules/fast-uri/benchmark/equal.mjs +51 -0
- package/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
- package/node_modules/fast-uri/benchmark/package.json +17 -0
- package/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
- package/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
- package/node_modules/fast-uri/index.js +95 -58
- package/node_modules/fast-uri/lib/schemes.js +160 -81
- package/node_modules/fast-uri/lib/utils.js +214 -122
- package/node_modules/fast-uri/package.json +7 -6
- package/node_modules/fast-uri/test/ajv.test.js +7 -3
- package/node_modules/fast-uri/test/equal.test.js +7 -2
- package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +501 -0
- package/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
- package/node_modules/fast-uri/test/parse.test.js +31 -31
- package/node_modules/fast-uri/test/resolve.test.js +52 -49
- package/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
- package/node_modules/fast-uri/test/serialize.test.js +55 -47
- package/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
- package/node_modules/fast-uri/test/uri-js.test.js +230 -230
- package/node_modules/fast-uri/test/util.test.js +23 -8
- package/node_modules/fast-uri/tsconfig.json +9 -0
- package/node_modules/fast-uri/types/index.d.ts +7 -0
- package/package.json +1 -1
- package/node_modules/fast-uri/benchmark.js +0 -105
- package/node_modules/fast-uri/lib/scopedChars.js +0 -30
- package/node_modules/fast-uri/test/.gitkeep +0 -0
- package/node_modules/fast-uri/test/compatibility.test.js +0 -131
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const test = require('tape')
|
|
4
|
-
const
|
|
4
|
+
const fastURI = require('..')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* URI.js
|
|
@@ -40,7 +40,7 @@ const URI = require('../index')
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
test('Acquire URI', (t) => {
|
|
43
|
-
t.ok(
|
|
43
|
+
t.ok(fastURI)
|
|
44
44
|
t.end()
|
|
45
45
|
})
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ test('URI Parsing', (t) => {
|
|
|
48
48
|
let components
|
|
49
49
|
|
|
50
50
|
// scheme
|
|
51
|
-
components =
|
|
51
|
+
components = fastURI.parse('uri:')
|
|
52
52
|
t.equal(components.error, undefined, 'scheme errors')
|
|
53
53
|
t.equal(components.scheme, 'uri', 'scheme')
|
|
54
54
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -59,7 +59,7 @@ test('URI Parsing', (t) => {
|
|
|
59
59
|
t.equal(components.fragment, undefined, 'fragment')
|
|
60
60
|
|
|
61
61
|
// userinfo
|
|
62
|
-
components =
|
|
62
|
+
components = fastURI.parse('//@')
|
|
63
63
|
t.equal(components.error, undefined, 'userinfo errors')
|
|
64
64
|
t.equal(components.scheme, undefined, 'scheme')
|
|
65
65
|
t.equal(components.userinfo, '', 'userinfo')
|
|
@@ -70,7 +70,7 @@ test('URI Parsing', (t) => {
|
|
|
70
70
|
t.equal(components.fragment, undefined, 'fragment')
|
|
71
71
|
|
|
72
72
|
// host
|
|
73
|
-
components =
|
|
73
|
+
components = fastURI.parse('//')
|
|
74
74
|
t.equal(components.error, undefined, 'host errors')
|
|
75
75
|
t.equal(components.scheme, undefined, 'scheme')
|
|
76
76
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -81,7 +81,7 @@ test('URI Parsing', (t) => {
|
|
|
81
81
|
t.equal(components.fragment, undefined, 'fragment')
|
|
82
82
|
|
|
83
83
|
// port
|
|
84
|
-
components =
|
|
84
|
+
components = fastURI.parse('//:')
|
|
85
85
|
t.equal(components.error, undefined, 'port errors')
|
|
86
86
|
t.equal(components.scheme, undefined, 'scheme')
|
|
87
87
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -92,7 +92,7 @@ test('URI Parsing', (t) => {
|
|
|
92
92
|
t.equal(components.fragment, undefined, 'fragment')
|
|
93
93
|
|
|
94
94
|
// path
|
|
95
|
-
components =
|
|
95
|
+
components = fastURI.parse('')
|
|
96
96
|
t.equal(components.error, undefined, 'path errors')
|
|
97
97
|
t.equal(components.scheme, undefined, 'scheme')
|
|
98
98
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -103,7 +103,7 @@ test('URI Parsing', (t) => {
|
|
|
103
103
|
t.equal(components.fragment, undefined, 'fragment')
|
|
104
104
|
|
|
105
105
|
// query
|
|
106
|
-
components =
|
|
106
|
+
components = fastURI.parse('?')
|
|
107
107
|
t.equal(components.error, undefined, 'query errors')
|
|
108
108
|
t.equal(components.scheme, undefined, 'scheme')
|
|
109
109
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -114,7 +114,7 @@ test('URI Parsing', (t) => {
|
|
|
114
114
|
t.equal(components.fragment, undefined, 'fragment')
|
|
115
115
|
|
|
116
116
|
// fragment
|
|
117
|
-
components =
|
|
117
|
+
components = fastURI.parse('#')
|
|
118
118
|
t.equal(components.error, undefined, 'fragment errors')
|
|
119
119
|
t.equal(components.scheme, undefined, 'scheme')
|
|
120
120
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -125,7 +125,7 @@ test('URI Parsing', (t) => {
|
|
|
125
125
|
t.equal(components.fragment, '', 'fragment')
|
|
126
126
|
|
|
127
127
|
// fragment with character tabulation
|
|
128
|
-
components =
|
|
128
|
+
components = fastURI.parse('#\t')
|
|
129
129
|
t.equal(components.error, undefined, 'path errors')
|
|
130
130
|
t.equal(components.scheme, undefined, 'scheme')
|
|
131
131
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -136,7 +136,7 @@ test('URI Parsing', (t) => {
|
|
|
136
136
|
t.equal(components.fragment, '%09', 'fragment')
|
|
137
137
|
|
|
138
138
|
// fragment with line feed
|
|
139
|
-
components =
|
|
139
|
+
components = fastURI.parse('#\n')
|
|
140
140
|
t.equal(components.error, undefined, 'path errors')
|
|
141
141
|
t.equal(components.scheme, undefined, 'scheme')
|
|
142
142
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -147,7 +147,7 @@ test('URI Parsing', (t) => {
|
|
|
147
147
|
t.equal(components.fragment, '%0A', 'fragment')
|
|
148
148
|
|
|
149
149
|
// fragment with line tabulation
|
|
150
|
-
components =
|
|
150
|
+
components = fastURI.parse('#\v')
|
|
151
151
|
t.equal(components.error, undefined, 'path errors')
|
|
152
152
|
t.equal(components.scheme, undefined, 'scheme')
|
|
153
153
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -158,7 +158,7 @@ test('URI Parsing', (t) => {
|
|
|
158
158
|
t.equal(components.fragment, '%0B', 'fragment')
|
|
159
159
|
|
|
160
160
|
// fragment with form feed
|
|
161
|
-
components =
|
|
161
|
+
components = fastURI.parse('#\f')
|
|
162
162
|
t.equal(components.error, undefined, 'path errors')
|
|
163
163
|
t.equal(components.scheme, undefined, 'scheme')
|
|
164
164
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -169,7 +169,7 @@ test('URI Parsing', (t) => {
|
|
|
169
169
|
t.equal(components.fragment, '%0C', 'fragment')
|
|
170
170
|
|
|
171
171
|
// fragment with carriage return
|
|
172
|
-
components =
|
|
172
|
+
components = fastURI.parse('#\r')
|
|
173
173
|
t.equal(components.error, undefined, 'path errors')
|
|
174
174
|
t.equal(components.scheme, undefined, 'scheme')
|
|
175
175
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -180,7 +180,7 @@ test('URI Parsing', (t) => {
|
|
|
180
180
|
t.equal(components.fragment, '%0D', 'fragment')
|
|
181
181
|
|
|
182
182
|
// all
|
|
183
|
-
components =
|
|
183
|
+
components = fastURI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
|
|
184
184
|
t.equal(components.error, undefined, 'all errors')
|
|
185
185
|
t.equal(components.scheme, 'uri', 'scheme')
|
|
186
186
|
t.equal(components.userinfo, 'user:pass', 'userinfo')
|
|
@@ -191,7 +191,7 @@ test('URI Parsing', (t) => {
|
|
|
191
191
|
t.equal(components.fragment, 'body', 'fragment')
|
|
192
192
|
|
|
193
193
|
// IPv4address
|
|
194
|
-
components =
|
|
194
|
+
components = fastURI.parse('//10.10.10.10')
|
|
195
195
|
t.equal(components.error, undefined, 'IPv4address errors')
|
|
196
196
|
t.equal(components.scheme, undefined, 'scheme')
|
|
197
197
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -202,7 +202,7 @@ test('URI Parsing', (t) => {
|
|
|
202
202
|
t.equal(components.fragment, undefined, 'fragment')
|
|
203
203
|
|
|
204
204
|
// IPv6address
|
|
205
|
-
components =
|
|
205
|
+
components = fastURI.parse('//[2001:db8::7]')
|
|
206
206
|
t.equal(components.error, undefined, 'IPv4address errors')
|
|
207
207
|
t.equal(components.scheme, undefined, 'scheme')
|
|
208
208
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -213,7 +213,7 @@ test('URI Parsing', (t) => {
|
|
|
213
213
|
t.equal(components.fragment, undefined, 'fragment')
|
|
214
214
|
|
|
215
215
|
// mixed IPv4address & IPv6address
|
|
216
|
-
components =
|
|
216
|
+
components = fastURI.parse('//[::ffff:129.144.52.38]')
|
|
217
217
|
t.equal(components.error, undefined, 'IPv4address errors')
|
|
218
218
|
t.equal(components.scheme, undefined, 'scheme')
|
|
219
219
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -224,7 +224,7 @@ test('URI Parsing', (t) => {
|
|
|
224
224
|
t.equal(components.fragment, undefined, 'fragment')
|
|
225
225
|
|
|
226
226
|
// mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
|
|
227
|
-
components =
|
|
227
|
+
components = fastURI.parse('uri://10.10.10.10.example.com/en/process')
|
|
228
228
|
t.equal(components.error, undefined, 'mixed errors')
|
|
229
229
|
t.equal(components.scheme, 'uri', 'scheme')
|
|
230
230
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -235,7 +235,7 @@ test('URI Parsing', (t) => {
|
|
|
235
235
|
t.equal(components.fragment, undefined, 'fragment')
|
|
236
236
|
|
|
237
237
|
// IPv6address, example from bkw (https://github.com/garycourt/uri-js/pull/16)
|
|
238
|
-
components =
|
|
238
|
+
components = fastURI.parse('//[2606:2800:220:1:248:1893:25c8:1946]/test')
|
|
239
239
|
t.equal(components.error, undefined, 'IPv6address errors')
|
|
240
240
|
t.equal(components.scheme, undefined, 'scheme')
|
|
241
241
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -246,7 +246,7 @@ test('URI Parsing', (t) => {
|
|
|
246
246
|
t.equal(components.fragment, undefined, 'fragment')
|
|
247
247
|
|
|
248
248
|
// IPv6address, example from RFC 5952
|
|
249
|
-
components =
|
|
249
|
+
components = fastURI.parse('//[2001:db8::1]:80')
|
|
250
250
|
t.equal(components.error, undefined, 'IPv6address errors')
|
|
251
251
|
t.equal(components.scheme, undefined, 'scheme')
|
|
252
252
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -257,7 +257,7 @@ test('URI Parsing', (t) => {
|
|
|
257
257
|
t.equal(components.fragment, undefined, 'fragment')
|
|
258
258
|
|
|
259
259
|
// IPv6address with zone identifier, RFC 6874
|
|
260
|
-
components =
|
|
260
|
+
components = fastURI.parse('//[fe80::a%25en1]')
|
|
261
261
|
t.equal(components.error, undefined, 'IPv4address errors')
|
|
262
262
|
t.equal(components.scheme, undefined, 'scheme')
|
|
263
263
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -268,7 +268,7 @@ test('URI Parsing', (t) => {
|
|
|
268
268
|
t.equal(components.fragment, undefined, 'fragment')
|
|
269
269
|
|
|
270
270
|
// IPv6address with an unescaped interface specifier, example from pekkanikander (https://github.com/garycourt/uri-js/pull/22)
|
|
271
|
-
components =
|
|
271
|
+
components = fastURI.parse('//[2001:db8::7%en0]')
|
|
272
272
|
t.equal(components.error, undefined, 'IPv6address interface errors')
|
|
273
273
|
t.equal(components.scheme, undefined, 'scheme')
|
|
274
274
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -291,7 +291,7 @@ test('URI Serialization', (t) => {
|
|
|
291
291
|
query: undefined,
|
|
292
292
|
fragment: undefined
|
|
293
293
|
}
|
|
294
|
-
t.equal(
|
|
294
|
+
t.equal(fastURI.serialize(components), '', 'Undefined Components')
|
|
295
295
|
|
|
296
296
|
components = {
|
|
297
297
|
scheme: '',
|
|
@@ -302,7 +302,7 @@ test('URI Serialization', (t) => {
|
|
|
302
302
|
query: '',
|
|
303
303
|
fragment: ''
|
|
304
304
|
}
|
|
305
|
-
t.equal(
|
|
305
|
+
t.equal(fastURI.serialize(components), '//@:0?#', 'Empty Components')
|
|
306
306
|
|
|
307
307
|
components = {
|
|
308
308
|
scheme: 'uri',
|
|
@@ -313,30 +313,30 @@ test('URI Serialization', (t) => {
|
|
|
313
313
|
query: 'query',
|
|
314
314
|
fragment: 'fragment'
|
|
315
315
|
}
|
|
316
|
-
t.equal(
|
|
316
|
+
t.equal(fastURI.serialize(components), 'uri://foo:bar@example.com:1/path?query#fragment', 'All Components')
|
|
317
317
|
|
|
318
318
|
components = {
|
|
319
319
|
scheme: 'uri',
|
|
320
320
|
host: 'example.com',
|
|
321
321
|
port: '9000'
|
|
322
322
|
}
|
|
323
|
-
t.equal(
|
|
323
|
+
t.equal(fastURI.serialize(components), 'uri://example.com:9000', 'String port')
|
|
324
324
|
|
|
325
|
-
t.equal(
|
|
326
|
-
t.equal(
|
|
327
|
-
t.equal(
|
|
325
|
+
t.equal(fastURI.serialize({ path: '//path' }), '/%2Fpath', 'Double slash path')
|
|
326
|
+
t.equal(fastURI.serialize({ path: 'foo:bar' }), 'foo%3Abar', 'Colon path')
|
|
327
|
+
t.equal(fastURI.serialize({ path: '?query' }), '%3Fquery', 'Query path')
|
|
328
328
|
|
|
329
329
|
// mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
|
|
330
|
-
t.equal(
|
|
330
|
+
t.equal(fastURI.serialize({ host: '10.10.10.10.example.com' }), '//10.10.10.10.example.com', 'Mixed IPv4address & reg-name')
|
|
331
331
|
|
|
332
332
|
// IPv6address
|
|
333
|
-
t.equal(
|
|
334
|
-
t.equal(
|
|
335
|
-
t.equal(
|
|
333
|
+
t.equal(fastURI.serialize({ host: '2001:db8::7' }), '//[2001:db8::7]', 'IPv6 Host')
|
|
334
|
+
t.equal(fastURI.serialize({ host: '::ffff:129.144.52.38' }), '//[::ffff:129.144.52.38]', 'IPv6 Mixed Host')
|
|
335
|
+
t.equal(fastURI.serialize({ host: '2606:2800:220:1:248:1893:25c8:1946' }), '//[2606:2800:220:1:248:1893:25c8:1946]', 'IPv6 Full Host')
|
|
336
336
|
|
|
337
337
|
// IPv6address with zone identifier, RFC 6874
|
|
338
|
-
t.equal(
|
|
339
|
-
t.equal(
|
|
338
|
+
t.equal(fastURI.serialize({ host: 'fe80::a%en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Unescaped Host')
|
|
339
|
+
t.equal(fastURI.serialize({ host: 'fe80::a%25en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Escaped Host')
|
|
340
340
|
|
|
341
341
|
t.end()
|
|
342
342
|
})
|
|
@@ -344,96 +344,96 @@ test('URI Serialization', (t) => {
|
|
|
344
344
|
test('URI Resolving', { skip: true }, (t) => {
|
|
345
345
|
// normal examples from RFC 3986
|
|
346
346
|
const base = 'uri://a/b/c/d;p?q'
|
|
347
|
-
t.equal(
|
|
348
|
-
t.equal(
|
|
349
|
-
t.equal(
|
|
350
|
-
t.equal(
|
|
351
|
-
t.equal(
|
|
352
|
-
t.equal(
|
|
353
|
-
t.equal(
|
|
354
|
-
t.equal(
|
|
355
|
-
t.equal(
|
|
356
|
-
t.equal(
|
|
357
|
-
t.equal(
|
|
358
|
-
t.equal(
|
|
359
|
-
t.equal(
|
|
360
|
-
t.equal(
|
|
361
|
-
t.equal(
|
|
362
|
-
t.equal(
|
|
363
|
-
t.equal(
|
|
364
|
-
t.equal(
|
|
365
|
-
t.equal(
|
|
366
|
-
t.equal(
|
|
367
|
-
t.equal(
|
|
368
|
-
t.equal(
|
|
369
|
-
t.equal(
|
|
347
|
+
t.equal(fastURI.resolve(base, 'g:h'), 'g:h', 'g:h')
|
|
348
|
+
t.equal(fastURI.resolve(base, 'g'), 'uri://a/b/c/g', 'g')
|
|
349
|
+
t.equal(fastURI.resolve(base, './g'), 'uri://a/b/c/g', './g')
|
|
350
|
+
t.equal(fastURI.resolve(base, 'g/'), 'uri://a/b/c/g/', 'g/')
|
|
351
|
+
t.equal(fastURI.resolve(base, '/g'), 'uri://a/g', '/g')
|
|
352
|
+
t.equal(fastURI.resolve(base, '//g'), 'uri://g', '//g')
|
|
353
|
+
t.equal(fastURI.resolve(base, '?y'), 'uri://a/b/c/d;p?y', '?y')
|
|
354
|
+
t.equal(fastURI.resolve(base, 'g?y'), 'uri://a/b/c/g?y', 'g?y')
|
|
355
|
+
t.equal(fastURI.resolve(base, '#s'), 'uri://a/b/c/d;p?q#s', '#s')
|
|
356
|
+
t.equal(fastURI.resolve(base, 'g#s'), 'uri://a/b/c/g#s', 'g#s')
|
|
357
|
+
t.equal(fastURI.resolve(base, 'g?y#s'), 'uri://a/b/c/g?y#s', 'g?y#s')
|
|
358
|
+
t.equal(fastURI.resolve(base, ';x'), 'uri://a/b/c/;x', ';x')
|
|
359
|
+
t.equal(fastURI.resolve(base, 'g;x'), 'uri://a/b/c/g;x', 'g;x')
|
|
360
|
+
t.equal(fastURI.resolve(base, 'g;x?y#s'), 'uri://a/b/c/g;x?y#s', 'g;x?y#s')
|
|
361
|
+
t.equal(fastURI.resolve(base, ''), 'uri://a/b/c/d;p?q', '')
|
|
362
|
+
t.equal(fastURI.resolve(base, '.'), 'uri://a/b/c/', '.')
|
|
363
|
+
t.equal(fastURI.resolve(base, './'), 'uri://a/b/c/', './')
|
|
364
|
+
t.equal(fastURI.resolve(base, '..'), 'uri://a/b/', '..')
|
|
365
|
+
t.equal(fastURI.resolve(base, '../'), 'uri://a/b/', '../')
|
|
366
|
+
t.equal(fastURI.resolve(base, '../g'), 'uri://a/b/g', '../g')
|
|
367
|
+
t.equal(fastURI.resolve(base, '../..'), 'uri://a/', '../..')
|
|
368
|
+
t.equal(fastURI.resolve(base, '../../'), 'uri://a/', '../../')
|
|
369
|
+
t.equal(fastURI.resolve(base, '../../g'), 'uri://a/g', '../../g')
|
|
370
370
|
|
|
371
371
|
// abnormal examples from RFC 3986
|
|
372
|
-
t.equal(
|
|
373
|
-
t.equal(
|
|
374
|
-
|
|
375
|
-
t.equal(
|
|
376
|
-
t.equal(
|
|
377
|
-
t.equal(
|
|
378
|
-
t.equal(
|
|
379
|
-
t.equal(
|
|
380
|
-
t.equal(
|
|
381
|
-
|
|
382
|
-
t.equal(
|
|
383
|
-
t.equal(
|
|
384
|
-
t.equal(
|
|
385
|
-
t.equal(
|
|
386
|
-
t.equal(
|
|
387
|
-
t.equal(
|
|
388
|
-
|
|
389
|
-
t.equal(
|
|
390
|
-
t.equal(
|
|
391
|
-
t.equal(
|
|
392
|
-
t.equal(
|
|
393
|
-
|
|
394
|
-
t.equal(
|
|
395
|
-
t.equal(
|
|
372
|
+
t.equal(fastURI.resolve(base, '../../../g'), 'uri://a/g', '../../../g')
|
|
373
|
+
t.equal(fastURI.resolve(base, '../../../../g'), 'uri://a/g', '../../../../g')
|
|
374
|
+
|
|
375
|
+
t.equal(fastURI.resolve(base, '/./g'), 'uri://a/g', '/./g')
|
|
376
|
+
t.equal(fastURI.resolve(base, '/../g'), 'uri://a/g', '/../g')
|
|
377
|
+
t.equal(fastURI.resolve(base, 'g.'), 'uri://a/b/c/g.', 'g.')
|
|
378
|
+
t.equal(fastURI.resolve(base, '.g'), 'uri://a/b/c/.g', '.g')
|
|
379
|
+
t.equal(fastURI.resolve(base, 'g..'), 'uri://a/b/c/g..', 'g..')
|
|
380
|
+
t.equal(fastURI.resolve(base, '..g'), 'uri://a/b/c/..g', '..g')
|
|
381
|
+
|
|
382
|
+
t.equal(fastURI.resolve(base, './../g'), 'uri://a/b/g', './../g')
|
|
383
|
+
t.equal(fastURI.resolve(base, './g/.'), 'uri://a/b/c/g/', './g/.')
|
|
384
|
+
t.equal(fastURI.resolve(base, 'g/./h'), 'uri://a/b/c/g/h', 'g/./h')
|
|
385
|
+
t.equal(fastURI.resolve(base, 'g/../h'), 'uri://a/b/c/h', 'g/../h')
|
|
386
|
+
t.equal(fastURI.resolve(base, 'g;x=1/./y'), 'uri://a/b/c/g;x=1/y', 'g;x=1/./y')
|
|
387
|
+
t.equal(fastURI.resolve(base, 'g;x=1/../y'), 'uri://a/b/c/y', 'g;x=1/../y')
|
|
388
|
+
|
|
389
|
+
t.equal(fastURI.resolve(base, 'g?y/./x'), 'uri://a/b/c/g?y/./x', 'g?y/./x')
|
|
390
|
+
t.equal(fastURI.resolve(base, 'g?y/../x'), 'uri://a/b/c/g?y/../x', 'g?y/../x')
|
|
391
|
+
t.equal(fastURI.resolve(base, 'g#s/./x'), 'uri://a/b/c/g#s/./x', 'g#s/./x')
|
|
392
|
+
t.equal(fastURI.resolve(base, 'g#s/../x'), 'uri://a/b/c/g#s/../x', 'g#s/../x')
|
|
393
|
+
|
|
394
|
+
t.equal(fastURI.resolve(base, 'uri:g'), 'uri:g', 'uri:g')
|
|
395
|
+
t.equal(fastURI.resolve(base, 'uri:g', { tolerant: true }), 'uri://a/b/c/g', 'uri:g')
|
|
396
396
|
|
|
397
397
|
// examples by PAEz
|
|
398
|
-
t.equal(
|
|
399
|
-
t.equal(
|
|
398
|
+
t.equal(fastURI.resolve('//www.g.com/', '/adf\ngf'), '//www.g.com/adf%0Agf', '/adf\\ngf')
|
|
399
|
+
t.equal(fastURI.resolve('//www.g.com/error\n/bleh/bleh', '..'), '//www.g.com/error%0A/', '//www.g.com/error\\n/bleh/bleh')
|
|
400
400
|
|
|
401
401
|
t.end()
|
|
402
402
|
})
|
|
403
403
|
|
|
404
404
|
test('URI Normalizing', { skip: true }, (t) => {
|
|
405
405
|
// test from RFC 3987
|
|
406
|
-
t.equal(
|
|
406
|
+
t.equal(fastURI.normalize('uri://www.example.org/red%09ros\xE9#red'), 'uri://www.example.org/red%09ros%C3%A9#red')
|
|
407
407
|
|
|
408
408
|
// IPv4address
|
|
409
|
-
t.equal(
|
|
409
|
+
t.equal(fastURI.normalize('//192.068.001.000'), '//192.68.1.0')
|
|
410
410
|
|
|
411
411
|
// IPv6address, example from RFC 3513
|
|
412
|
-
t.equal(
|
|
412
|
+
t.equal(fastURI.normalize('http://[1080::8:800:200C:417A]/'), 'http://[1080::8:800:200c:417a]/')
|
|
413
413
|
|
|
414
414
|
// IPv6address, examples from RFC 5952
|
|
415
|
-
t.equal(
|
|
416
|
-
t.equal(
|
|
417
|
-
t.equal(
|
|
418
|
-
t.equal(
|
|
419
|
-
t.equal(
|
|
420
|
-
t.equal(
|
|
421
|
-
t.equal(
|
|
422
|
-
t.equal(
|
|
415
|
+
t.equal(fastURI.normalize('//[2001:0db8::0001]/'), '//[2001:db8::1]/')
|
|
416
|
+
t.equal(fastURI.normalize('//[2001:db8::1:0000:1]/'), '//[2001:db8::1:0:1]/')
|
|
417
|
+
t.equal(fastURI.normalize('//[2001:db8:0:0:0:0:2:1]/'), '//[2001:db8::2:1]/')
|
|
418
|
+
t.equal(fastURI.normalize('//[2001:db8:0:1:1:1:1:1]/'), '//[2001:db8:0:1:1:1:1:1]/')
|
|
419
|
+
t.equal(fastURI.normalize('//[2001:0:0:1:0:0:0:1]/'), '//[2001:0:0:1::1]/')
|
|
420
|
+
t.equal(fastURI.normalize('//[2001:db8:0:0:1:0:0:1]/'), '//[2001:db8::1:0:0:1]/')
|
|
421
|
+
t.equal(fastURI.normalize('//[2001:DB8::1]/'), '//[2001:db8::1]/')
|
|
422
|
+
t.equal(fastURI.normalize('//[0:0:0:0:0:ffff:192.0.2.1]/'), '//[::ffff:192.0.2.1]/')
|
|
423
423
|
|
|
424
424
|
// Mixed IPv4 and IPv6 address
|
|
425
|
-
t.equal(
|
|
426
|
-
t.equal(
|
|
425
|
+
t.equal(fastURI.normalize('//[1:2:3:4:5:6:192.0.2.1]/'), '//[1:2:3:4:5:6:192.0.2.1]/')
|
|
426
|
+
t.equal(fastURI.normalize('//[1:2:3:4:5:6:192.068.001.000]/'), '//[1:2:3:4:5:6:192.68.1.0]/')
|
|
427
427
|
|
|
428
428
|
t.end()
|
|
429
429
|
})
|
|
430
430
|
|
|
431
431
|
test('URI Equals', (t) => {
|
|
432
432
|
// test from RFC 3986
|
|
433
|
-
t.equal(
|
|
433
|
+
t.equal(fastURI.equal('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'), true)
|
|
434
434
|
|
|
435
435
|
// test from RFC 3987
|
|
436
|
-
t.equal(
|
|
436
|
+
t.equal(fastURI.equal('http://example.org/~user', 'http://example.org/%7euser'), true)
|
|
437
437
|
|
|
438
438
|
t.end()
|
|
439
439
|
})
|
|
@@ -443,15 +443,15 @@ test('Escape Component', { skip: true }, (t) => {
|
|
|
443
443
|
for (let d = 0; d <= 129; ++d) {
|
|
444
444
|
chr = String.fromCharCode(d)
|
|
445
445
|
if (!chr.match(/[$&+,;=]/)) {
|
|
446
|
-
t.equal(
|
|
446
|
+
t.equal(fastURI.escapeComponent(chr), encodeURIComponent(chr))
|
|
447
447
|
} else {
|
|
448
|
-
t.equal(
|
|
448
|
+
t.equal(fastURI.escapeComponent(chr), chr)
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
t.equal(
|
|
452
|
-
t.equal(
|
|
453
|
-
t.equal(
|
|
454
|
-
t.equal(
|
|
451
|
+
t.equal(fastURI.escapeComponent('\u00c0'), encodeURIComponent('\u00c0'))
|
|
452
|
+
t.equal(fastURI.escapeComponent('\u07ff'), encodeURIComponent('\u07ff'))
|
|
453
|
+
t.equal(fastURI.escapeComponent('\u0800'), encodeURIComponent('\u0800'))
|
|
454
|
+
t.equal(fastURI.escapeComponent('\u30a2'), encodeURIComponent('\u30a2'))
|
|
455
455
|
t.end()
|
|
456
456
|
})
|
|
457
457
|
|
|
@@ -459,19 +459,19 @@ test('Unescape Component', { skip: true }, (t) => {
|
|
|
459
459
|
let chr
|
|
460
460
|
for (let d = 0; d <= 129; ++d) {
|
|
461
461
|
chr = String.fromCharCode(d)
|
|
462
|
-
t.equal(
|
|
462
|
+
t.equal(fastURI.unescapeComponent(encodeURIComponent(chr)), chr)
|
|
463
463
|
}
|
|
464
|
-
t.equal(
|
|
465
|
-
t.equal(
|
|
466
|
-
t.equal(
|
|
467
|
-
t.equal(
|
|
464
|
+
t.equal(fastURI.unescapeComponent(encodeURIComponent('\u00c0')), '\u00c0')
|
|
465
|
+
t.equal(fastURI.unescapeComponent(encodeURIComponent('\u07ff')), '\u07ff')
|
|
466
|
+
t.equal(fastURI.unescapeComponent(encodeURIComponent('\u0800')), '\u0800')
|
|
467
|
+
t.equal(fastURI.unescapeComponent(encodeURIComponent('\u30a2')), '\u30a2')
|
|
468
468
|
t.end()
|
|
469
469
|
})
|
|
470
470
|
|
|
471
471
|
const IRI_OPTION = { iri: true, unicodeSupport: true }
|
|
472
472
|
|
|
473
473
|
test('IRI Parsing', { skip: true }, (t) => {
|
|
474
|
-
const components =
|
|
474
|
+
const components = fastURI.parse('uri://us\xA0er:pa\uD7FFss@example.com:123/o\uF900ne/t\uFDCFwo.t\uFDF0hree?q1=a1\uF8FF\uE000&q2=a2#bo\uFFEFdy', IRI_OPTION)
|
|
475
475
|
t.equal(components.error, undefined, 'all errors')
|
|
476
476
|
t.equal(components.scheme, 'uri', 'scheme')
|
|
477
477
|
t.equal(components.userinfo, 'us\xA0er:pa\uD7FFss', 'userinfo')
|
|
@@ -493,66 +493,66 @@ test('IRI Serialization', { skip: true }, (t) => {
|
|
|
493
493
|
query: 'q1=a1\uF8FF\uE000&q2=a2',
|
|
494
494
|
fragment: 'bo\uFFEFdy\uE001'
|
|
495
495
|
}
|
|
496
|
-
t.equal(
|
|
496
|
+
t.equal(fastURI.serialize(components, IRI_OPTION), 'uri://us\xA0er:pa\uD7FFss@example.com:123/o\uF900ne/t\uFDCFwo.t\uFDF0hree?q1=a1\uF8FF\uE000&q2=a2#bo\uFFEFdy%EE%80%81')
|
|
497
497
|
t.end()
|
|
498
498
|
})
|
|
499
499
|
|
|
500
500
|
test('IRI Normalizing', { skip: true }, (t) => {
|
|
501
|
-
t.equal(
|
|
501
|
+
t.equal(fastURI.normalize('uri://www.example.org/red%09ros\xE9#red', IRI_OPTION), 'uri://www.example.org/red%09ros\xE9#red')
|
|
502
502
|
t.end()
|
|
503
503
|
})
|
|
504
504
|
|
|
505
505
|
test('IRI Equals', { skip: true }, (t) => {
|
|
506
506
|
// example from RFC 3987
|
|
507
|
-
t.equal(
|
|
507
|
+
t.equal(fastURI.equal('example://a/b/c/%7Bfoo%7D/ros\xE9', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d/ros%C3%A9', IRI_OPTION), true)
|
|
508
508
|
t.end()
|
|
509
509
|
})
|
|
510
510
|
|
|
511
511
|
test('Convert IRI to URI', { skip: true }, (t) => {
|
|
512
512
|
// example from RFC 3987
|
|
513
|
-
t.equal(
|
|
513
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://www.example.org/red%09ros\xE9#red', IRI_OPTION)), 'uri://www.example.org/red%09ros%C3%A9#red')
|
|
514
514
|
|
|
515
515
|
// Internationalized Domain Name conversion via punycode example from RFC 3987
|
|
516
|
-
t.equal(
|
|
516
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://r\xE9sum\xE9.example.org', { iri: true, domainHost: true }), { domainHost: true }), 'uri://xn--rsum-bpad.example.org')
|
|
517
517
|
t.end()
|
|
518
518
|
})
|
|
519
519
|
|
|
520
520
|
test('Convert URI to IRI', { skip: true }, (t) => {
|
|
521
521
|
// examples from RFC 3987
|
|
522
|
-
t.equal(
|
|
523
|
-
t.equal(
|
|
524
|
-
t.equal(
|
|
522
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://www.example.org/D%C3%BCrst'), IRI_OPTION), 'uri://www.example.org/D\xFCrst')
|
|
523
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://www.example.org/D%FCrst'), IRI_OPTION), 'uri://www.example.org/D%FCrst')
|
|
524
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://xn--99zt52a.example.org/%e2%80%ae'), IRI_OPTION), 'uri://xn--99zt52a.example.org/%E2%80%AE') // or uri://\u7D0D\u8C46.example.org/%E2%80%AE
|
|
525
525
|
|
|
526
526
|
// Internationalized Domain Name conversion via punycode example from RFC 3987
|
|
527
|
-
t.equal(
|
|
527
|
+
t.equal(fastURI.serialize(fastURI.parse('uri://xn--rsum-bpad.example.org', { domainHost: true }), { iri: true, domainHost: true }), 'uri://r\xE9sum\xE9.example.org')
|
|
528
528
|
t.end()
|
|
529
529
|
})
|
|
530
530
|
|
|
531
|
-
if (
|
|
531
|
+
if (fastURI.SCHEMES.http) {
|
|
532
532
|
test('HTTP Equals', (t) => {
|
|
533
533
|
// test from RFC 2616
|
|
534
|
-
t.equal(
|
|
535
|
-
t.equal(
|
|
536
|
-
t.equal(
|
|
537
|
-
t.equal(
|
|
534
|
+
t.equal(fastURI.equal('http://abc.com:80/~smith/home.html', 'http://abc.com/~smith/home.html'), true)
|
|
535
|
+
t.equal(fastURI.equal('http://ABC.com/%7Esmith/home.html', 'http://abc.com/~smith/home.html'), true)
|
|
536
|
+
t.equal(fastURI.equal('http://ABC.com:/%7esmith/home.html', 'http://abc.com/~smith/home.html'), true)
|
|
537
|
+
t.equal(fastURI.equal('HTTP://ABC.COM', 'http://abc.com/'), true)
|
|
538
538
|
// test from RFC 3986
|
|
539
|
-
t.equal(
|
|
539
|
+
t.equal(fastURI.equal('http://example.com:/', 'http://example.com:80/'), true)
|
|
540
540
|
t.end()
|
|
541
541
|
})
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
-
if (
|
|
544
|
+
if (fastURI.SCHEMES.https) {
|
|
545
545
|
test('HTTPS Equals', (t) => {
|
|
546
|
-
t.equal(
|
|
547
|
-
t.equal(
|
|
546
|
+
t.equal(fastURI.equal('https://example.com', 'https://example.com:443/'), true)
|
|
547
|
+
t.equal(fastURI.equal('https://example.com:/', 'https://example.com:443/'), true)
|
|
548
548
|
t.end()
|
|
549
549
|
})
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
-
if (
|
|
552
|
+
if (fastURI.SCHEMES.urn) {
|
|
553
553
|
test('URN Parsing', (t) => {
|
|
554
554
|
// example from RFC 2141
|
|
555
|
-
const components =
|
|
555
|
+
const components = fastURI.parse('urn:foo:a123,456')
|
|
556
556
|
t.equal(components.error, undefined, 'errors')
|
|
557
557
|
t.equal(components.scheme, 'urn', 'scheme')
|
|
558
558
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -573,32 +573,32 @@ if (URI.SCHEMES.urn) {
|
|
|
573
573
|
nid: 'foo',
|
|
574
574
|
nss: 'a123,456'
|
|
575
575
|
}
|
|
576
|
-
t.equal(
|
|
576
|
+
t.equal(fastURI.serialize(components), 'urn:foo:a123,456')
|
|
577
577
|
t.end()
|
|
578
578
|
})
|
|
579
579
|
|
|
580
580
|
test('URN Equals', { skip: true }, (t) => {
|
|
581
581
|
// test from RFC 2141
|
|
582
|
-
t.equal(
|
|
583
|
-
t.equal(
|
|
584
|
-
t.equal(
|
|
585
|
-
t.equal(
|
|
586
|
-
t.equal(
|
|
582
|
+
t.equal(fastURI.equal('urn:foo:a123,456', 'urn:foo:a123,456'), true)
|
|
583
|
+
t.equal(fastURI.equal('urn:foo:a123,456', 'URN:foo:a123,456'), true)
|
|
584
|
+
t.equal(fastURI.equal('urn:foo:a123,456', 'urn:FOO:a123,456'), true)
|
|
585
|
+
t.equal(fastURI.equal('urn:foo:a123,456', 'urn:foo:A123,456'), false)
|
|
586
|
+
t.equal(fastURI.equal('urn:foo:a123%2C456', 'URN:FOO:a123%2c456'), true)
|
|
587
587
|
t.end()
|
|
588
588
|
})
|
|
589
589
|
|
|
590
590
|
test('URN Resolving', (t) => {
|
|
591
591
|
// example from epoberezkin
|
|
592
|
-
t.equal(
|
|
593
|
-
t.equal(
|
|
594
|
-
t.equal(
|
|
595
|
-
t.equal(
|
|
592
|
+
t.equal(fastURI.resolve('', 'urn:some:ip:prop'), 'urn:some:ip:prop')
|
|
593
|
+
t.equal(fastURI.resolve('#', 'urn:some:ip:prop'), 'urn:some:ip:prop')
|
|
594
|
+
t.equal(fastURI.resolve('urn:some:ip:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop')
|
|
595
|
+
t.equal(fastURI.resolve('urn:some:other:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop')
|
|
596
596
|
t.end()
|
|
597
597
|
})
|
|
598
598
|
|
|
599
599
|
test('UUID Parsing', (t) => {
|
|
600
600
|
// example from RFC 4122
|
|
601
|
-
let components =
|
|
601
|
+
let components = fastURI.parse('urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
|
|
602
602
|
t.equal(components.error, undefined, 'errors')
|
|
603
603
|
t.equal(components.scheme, 'urn', 'scheme')
|
|
604
604
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -611,7 +611,7 @@ if (URI.SCHEMES.urn) {
|
|
|
611
611
|
t.equal(components.nss, undefined, 'nss')
|
|
612
612
|
t.equal(components.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'uuid')
|
|
613
613
|
|
|
614
|
-
components =
|
|
614
|
+
components = fastURI.parse('urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
|
|
615
615
|
t.notEqual(components.error, undefined, 'errors')
|
|
616
616
|
t.end()
|
|
617
617
|
})
|
|
@@ -623,24 +623,24 @@ if (URI.SCHEMES.urn) {
|
|
|
623
623
|
nid: 'uuid',
|
|
624
624
|
uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
|
|
625
625
|
}
|
|
626
|
-
t.equal(
|
|
626
|
+
t.equal(fastURI.serialize(components), 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
|
|
627
627
|
|
|
628
628
|
components = {
|
|
629
629
|
scheme: 'urn',
|
|
630
630
|
nid: 'uuid',
|
|
631
631
|
uuid: 'notauuid-7dec-11d0-a765-00a0c91e6bf6'
|
|
632
632
|
}
|
|
633
|
-
t.equal(
|
|
633
|
+
t.equal(fastURI.serialize(components), 'urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
|
|
634
634
|
t.end()
|
|
635
635
|
})
|
|
636
636
|
|
|
637
637
|
test('UUID Equals', (t) => {
|
|
638
|
-
t.equal(
|
|
638
|
+
t.equal(fastURI.equal('URN:UUID:F81D4FAE-7DEC-11D0-A765-00A0C91E6BF6', 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6'), true)
|
|
639
639
|
t.end()
|
|
640
640
|
})
|
|
641
641
|
|
|
642
642
|
test('URN NID Override', (t) => {
|
|
643
|
-
let components =
|
|
643
|
+
let components = fastURI.parse('urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6', { nid: 'uuid' })
|
|
644
644
|
t.equal(components.error, undefined, 'errors')
|
|
645
645
|
t.equal(components.scheme, 'urn', 'scheme')
|
|
646
646
|
t.equal(components.path, undefined, 'path')
|
|
@@ -653,18 +653,18 @@ if (URI.SCHEMES.urn) {
|
|
|
653
653
|
nid: 'foo',
|
|
654
654
|
uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
|
|
655
655
|
}
|
|
656
|
-
t.equal(
|
|
656
|
+
t.equal(fastURI.serialize(components, { nid: 'uuid' }), 'urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
|
|
657
657
|
t.end()
|
|
658
658
|
})
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
if (
|
|
661
|
+
if (fastURI.SCHEMES.mailto) {
|
|
662
662
|
test('Mailto Parse', (t) => {
|
|
663
663
|
let components
|
|
664
664
|
|
|
665
665
|
// tests from RFC 6068
|
|
666
666
|
|
|
667
|
-
components =
|
|
667
|
+
components = fastURI.parse('mailto:chris@example.com')
|
|
668
668
|
t.equal(components.error, undefined, 'error')
|
|
669
669
|
t.equal(components.scheme, 'mailto', 'scheme')
|
|
670
670
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -678,72 +678,72 @@ if (URI.SCHEMES.mailto) {
|
|
|
678
678
|
t.equal(components.body, undefined, 'body')
|
|
679
679
|
t.equal(components.headers, undefined, 'headers')
|
|
680
680
|
|
|
681
|
-
components =
|
|
681
|
+
components = fastURI.parse('mailto:infobot@example.com?subject=current-issue')
|
|
682
682
|
t.deepEqual(components.to, ['infobot@example.com'], 'to')
|
|
683
683
|
t.equal(components.subject, 'current-issue', 'subject')
|
|
684
684
|
|
|
685
|
-
components =
|
|
685
|
+
components = fastURI.parse('mailto:infobot@example.com?body=send%20current-issue')
|
|
686
686
|
t.deepEqual(components.to, ['infobot@example.com'], 'to')
|
|
687
687
|
t.equal(components.body, 'send current-issue', 'body')
|
|
688
688
|
|
|
689
|
-
components =
|
|
689
|
+
components = fastURI.parse('mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index')
|
|
690
690
|
t.deepEqual(components.to, ['infobot@example.com'], 'to')
|
|
691
691
|
t.equal(components.body, 'send current-issue\x0D\x0Asend index', 'body')
|
|
692
692
|
|
|
693
|
-
components =
|
|
693
|
+
components = fastURI.parse('mailto:list@example.org?In-Reply-To=%3C3469A91.D10AF4C@example.com%3E')
|
|
694
694
|
t.deepEqual(components.to, ['list@example.org'], 'to')
|
|
695
695
|
t.deepEqual(components.headers, { 'In-Reply-To': '<3469A91.D10AF4C@example.com>' }, 'headers')
|
|
696
696
|
|
|
697
|
-
components =
|
|
697
|
+
components = fastURI.parse('mailto:majordomo@example.com?body=subscribe%20bamboo-l')
|
|
698
698
|
t.deepEqual(components.to, ['majordomo@example.com'], 'to')
|
|
699
699
|
t.equal(components.body, 'subscribe bamboo-l', 'body')
|
|
700
700
|
|
|
701
|
-
components =
|
|
701
|
+
components = fastURI.parse('mailto:joe@example.com?cc=bob@example.com&body=hello')
|
|
702
702
|
t.deepEqual(components.to, ['joe@example.com'], 'to')
|
|
703
703
|
t.equal(components.body, 'hello', 'body')
|
|
704
704
|
t.deepEqual(components.headers, { cc: 'bob@example.com' }, 'headers')
|
|
705
705
|
|
|
706
|
-
components =
|
|
707
|
-
if (
|
|
706
|
+
components = fastURI.parse('mailto:joe@example.com?cc=bob@example.com?body=hello')
|
|
707
|
+
if (fastURI.VALIDATE_SUPPORT) t.ok(components.error, 'invalid header fields')
|
|
708
708
|
|
|
709
|
-
components =
|
|
709
|
+
components = fastURI.parse('mailto:gorby%25kremvax@example.com')
|
|
710
710
|
t.deepEqual(components.to, ['gorby%kremvax@example.com'], 'to gorby%kremvax@example.com')
|
|
711
711
|
|
|
712
|
-
components =
|
|
712
|
+
components = fastURI.parse('mailto:unlikely%3Faddress@example.com?blat=foop')
|
|
713
713
|
t.deepEqual(components.to, ['unlikely?address@example.com'], 'to unlikely?address@example.com')
|
|
714
714
|
t.deepEqual(components.headers, { blat: 'foop' }, 'headers')
|
|
715
715
|
|
|
716
|
-
components =
|
|
716
|
+
components = fastURI.parse('mailto:Mike%26family@example.org')
|
|
717
717
|
t.deepEqual(components.to, ['Mike&family@example.org'], 'to Mike&family@example.org')
|
|
718
718
|
|
|
719
|
-
components =
|
|
719
|
+
components = fastURI.parse('mailto:%22not%40me%22@example.org')
|
|
720
720
|
t.deepEqual(components.to, ['"not@me"@example.org'], 'to ' + '"not@me"@example.org')
|
|
721
721
|
|
|
722
|
-
components =
|
|
722
|
+
components = fastURI.parse('mailto:%22oh%5C%5Cno%22@example.org')
|
|
723
723
|
t.deepEqual(components.to, ['"oh\\\\no"@example.org'], 'to ' + '"oh\\\\no"@example.org')
|
|
724
724
|
|
|
725
|
-
components =
|
|
725
|
+
components = fastURI.parse("mailto:%22%5C%5C%5C%22it's%5C%20ugly%5C%5C%5C%22%22@example.org")
|
|
726
726
|
t.deepEqual(components.to, ['"\\\\\\"it\'s\\ ugly\\\\\\""@example.org'], 'to ' + '"\\\\\\"it\'s\\ ugly\\\\\\""@example.org')
|
|
727
727
|
|
|
728
|
-
components =
|
|
728
|
+
components = fastURI.parse('mailto:user@example.org?subject=caf%C3%A9')
|
|
729
729
|
t.deepEqual(components.to, ['user@example.org'], 'to')
|
|
730
730
|
t.equal(components.subject, 'caf\xE9', 'subject')
|
|
731
731
|
|
|
732
|
-
components =
|
|
732
|
+
components = fastURI.parse('mailto:user@example.org?subject=%3D%3Futf-8%3FQ%3Fcaf%3DC3%3DA9%3F%3D')
|
|
733
733
|
t.deepEqual(components.to, ['user@example.org'], 'to')
|
|
734
734
|
t.equal(components.subject, '=?utf-8?Q?caf=C3=A9?=', 'subject') // TODO: Verify this
|
|
735
735
|
|
|
736
|
-
components =
|
|
736
|
+
components = fastURI.parse('mailto:user@example.org?subject=%3D%3Fiso-8859-1%3FQ%3Fcaf%3DE9%3F%3D')
|
|
737
737
|
t.deepEqual(components.to, ['user@example.org'], 'to')
|
|
738
738
|
t.equal(components.subject, '=?iso-8859-1?Q?caf=E9?=', 'subject') // TODO: Verify this
|
|
739
739
|
|
|
740
|
-
components =
|
|
740
|
+
components = fastURI.parse('mailto:user@example.org?subject=caf%C3%A9&body=caf%C3%A9')
|
|
741
741
|
t.deepEqual(components.to, ['user@example.org'], 'to')
|
|
742
742
|
t.equal(components.subject, 'caf\xE9', 'subject')
|
|
743
743
|
t.equal(components.body, 'caf\xE9', 'body')
|
|
744
744
|
|
|
745
|
-
if (
|
|
746
|
-
components =
|
|
745
|
+
if (fastURI.IRI_SUPPORT) {
|
|
746
|
+
components = fastURI.parse('mailto:user@%E7%B4%8D%E8%B1%86.example.org?subject=Test&body=NATTO')
|
|
747
747
|
t.deepEqual(components.to, ['user@xn--99zt52a.example.org'], 'to')
|
|
748
748
|
t.equal(components.subject, 'Test', 'subject')
|
|
749
749
|
t.equal(components.body, 'NATTO', 'body')
|
|
@@ -754,43 +754,43 @@ if (URI.SCHEMES.mailto) {
|
|
|
754
754
|
|
|
755
755
|
test('Mailto Serialize', (t) => {
|
|
756
756
|
// tests from RFC 6068
|
|
757
|
-
t.equal(
|
|
758
|
-
t.equal(
|
|
759
|
-
t.equal(
|
|
760
|
-
t.equal(
|
|
761
|
-
t.equal(
|
|
762
|
-
t.equal(
|
|
763
|
-
t.equal(
|
|
764
|
-
t.equal(
|
|
765
|
-
t.equal(
|
|
766
|
-
t.equal(
|
|
767
|
-
t.equal(
|
|
768
|
-
t.equal(
|
|
769
|
-
t.equal(
|
|
770
|
-
t.equal(
|
|
771
|
-
t.equal(
|
|
772
|
-
t.equal(
|
|
773
|
-
t.equal(
|
|
774
|
-
if (
|
|
775
|
-
t.equal(
|
|
757
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['chris@example.com'] }), 'mailto:chris@example.com')
|
|
758
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['infobot@example.com'], body: 'current-issue' }), 'mailto:infobot@example.com?body=current-issue')
|
|
759
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['infobot@example.com'], body: 'send current-issue' }), 'mailto:infobot@example.com?body=send%20current-issue')
|
|
760
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['infobot@example.com'], body: 'send current-issue\x0D\x0Asend index' }), 'mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index')
|
|
761
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['list@example.org'], headers: { 'In-Reply-To': '<3469A91.D10AF4C@example.com>' } }), 'mailto:list@example.org?In-Reply-To=%3C3469A91.D10AF4C@example.com%3E')
|
|
762
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['majordomo@example.com'], body: 'subscribe bamboo-l' }), 'mailto:majordomo@example.com?body=subscribe%20bamboo-l')
|
|
763
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['joe@example.com'], headers: { cc: 'bob@example.com', body: 'hello' } }), 'mailto:joe@example.com?cc=bob@example.com&body=hello')
|
|
764
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['gorby%25kremvax@example.com'] }), 'mailto:gorby%25kremvax@example.com')
|
|
765
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['unlikely%3Faddress@example.com'], headers: { blat: 'foop' } }), 'mailto:unlikely%3Faddress@example.com?blat=foop')
|
|
766
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['Mike&family@example.org'] }), 'mailto:Mike%26family@example.org')
|
|
767
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['"not@me"@example.org'] }), 'mailto:%22not%40me%22@example.org')
|
|
768
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['"oh\\\\no"@example.org'] }), 'mailto:%22oh%5C%5Cno%22@example.org')
|
|
769
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['"\\\\\\"it\'s\\ ugly\\\\\\""@example.org'] }), "mailto:%22%5C%5C%5C%22it's%5C%20ugly%5C%5C%5C%22%22@example.org")
|
|
770
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['user@example.org'], subject: 'caf\xE9' }), 'mailto:user@example.org?subject=caf%C3%A9')
|
|
771
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['user@example.org'], subject: '=?utf-8?Q?caf=C3=A9?=' }), 'mailto:user@example.org?subject=%3D%3Futf-8%3FQ%3Fcaf%3DC3%3DA9%3F%3D')
|
|
772
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['user@example.org'], subject: '=?iso-8859-1?Q?caf=E9?=' }), 'mailto:user@example.org?subject=%3D%3Fiso-8859-1%3FQ%3Fcaf%3DE9%3F%3D')
|
|
773
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['user@example.org'], subject: 'caf\xE9', body: 'caf\xE9' }), 'mailto:user@example.org?subject=caf%C3%A9&body=caf%C3%A9')
|
|
774
|
+
if (fastURI.IRI_SUPPORT) {
|
|
775
|
+
t.equal(fastURI.serialize({ scheme: 'mailto', to: ['us\xE9r@\u7d0d\u8c46.example.org'], subject: 'Test', body: 'NATTO' }), 'mailto:us%C3%A9r@xn--99zt52a.example.org?subject=Test&body=NATTO')
|
|
776
776
|
}
|
|
777
777
|
t.end()
|
|
778
778
|
})
|
|
779
779
|
|
|
780
780
|
test('Mailto Equals', (t) => {
|
|
781
781
|
// tests from RFC 6068
|
|
782
|
-
t.equal(
|
|
783
|
-
t.equal(
|
|
782
|
+
t.equal(fastURI.equal('mailto:addr1@an.example,addr2@an.example', 'mailto:?to=addr1@an.example,addr2@an.example'), true)
|
|
783
|
+
t.equal(fastURI.equal('mailto:?to=addr1@an.example,addr2@an.example', 'mailto:addr1@an.example?to=addr2@an.example'), true)
|
|
784
784
|
t.end()
|
|
785
785
|
})
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
-
if (
|
|
788
|
+
if (fastURI.SCHEMES.ws) {
|
|
789
789
|
test('WS Parse', (t) => {
|
|
790
790
|
let components
|
|
791
791
|
|
|
792
792
|
// example from RFC 6455, Sec 4.1
|
|
793
|
-
components =
|
|
793
|
+
components = fastURI.parse('ws://example.com/chat')
|
|
794
794
|
t.equal(components.error, undefined, 'error')
|
|
795
795
|
t.equal(components.scheme, 'ws', 'scheme')
|
|
796
796
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -802,7 +802,7 @@ if (URI.SCHEMES.ws) {
|
|
|
802
802
|
t.equal(components.resourceName, '/chat', 'resourceName')
|
|
803
803
|
t.equal(components.secure, false, 'secure')
|
|
804
804
|
|
|
805
|
-
components =
|
|
805
|
+
components = fastURI.parse('ws://example.com/foo?bar=baz')
|
|
806
806
|
t.equal(components.error, undefined, 'error')
|
|
807
807
|
t.equal(components.scheme, 'ws', 'scheme')
|
|
808
808
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -814,46 +814,46 @@ if (URI.SCHEMES.ws) {
|
|
|
814
814
|
t.equal(components.resourceName, '/foo?bar=baz', 'resourceName')
|
|
815
815
|
t.equal(components.secure, false, 'secure')
|
|
816
816
|
|
|
817
|
-
components =
|
|
817
|
+
components = fastURI.parse('ws://example.com/?bar=baz')
|
|
818
818
|
t.equal(components.resourceName, '/?bar=baz', 'resourceName')
|
|
819
819
|
|
|
820
820
|
t.end()
|
|
821
821
|
})
|
|
822
822
|
|
|
823
823
|
test('WS Serialize', (t) => {
|
|
824
|
-
t.equal(
|
|
825
|
-
t.equal(
|
|
826
|
-
t.equal(
|
|
827
|
-
t.equal(
|
|
828
|
-
t.equal(
|
|
829
|
-
t.equal(
|
|
830
|
-
t.equal(
|
|
831
|
-
t.equal(
|
|
832
|
-
t.equal(
|
|
833
|
-
t.equal(
|
|
834
|
-
t.equal(
|
|
835
|
-
t.equal(
|
|
836
|
-
t.equal(
|
|
824
|
+
t.equal(fastURI.serialize({ scheme: 'ws' }), 'ws:')
|
|
825
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com' }), 'ws://example.com')
|
|
826
|
+
t.equal(fastURI.serialize({ scheme: 'ws', resourceName: '/' }), 'ws:')
|
|
827
|
+
t.equal(fastURI.serialize({ scheme: 'ws', resourceName: '/foo' }), 'ws:/foo')
|
|
828
|
+
t.equal(fastURI.serialize({ scheme: 'ws', resourceName: '/foo?bar' }), 'ws:/foo?bar')
|
|
829
|
+
t.equal(fastURI.serialize({ scheme: 'ws', secure: false }), 'ws:')
|
|
830
|
+
t.equal(fastURI.serialize({ scheme: 'ws', secure: true }), 'wss:')
|
|
831
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo' }), 'ws://example.com/foo')
|
|
832
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar' }), 'ws://example.com/foo?bar')
|
|
833
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', secure: false }), 'ws://example.com')
|
|
834
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', secure: true }), 'wss://example.com')
|
|
835
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
|
|
836
|
+
t.equal(fastURI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
|
|
837
837
|
t.end()
|
|
838
838
|
})
|
|
839
839
|
|
|
840
840
|
test('WS Equal', (t) => {
|
|
841
|
-
t.equal(
|
|
841
|
+
t.equal(fastURI.equal('WS://ABC.COM:80/chat#one', 'ws://abc.com/chat'), true)
|
|
842
842
|
t.end()
|
|
843
843
|
})
|
|
844
844
|
|
|
845
845
|
test('WS Normalize', (t) => {
|
|
846
|
-
t.equal(
|
|
846
|
+
t.equal(fastURI.normalize('ws://example.com:80/foo#hash'), 'ws://example.com/foo')
|
|
847
847
|
t.end()
|
|
848
848
|
})
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
-
if (
|
|
851
|
+
if (fastURI.SCHEMES.wss) {
|
|
852
852
|
test('WSS Parse', (t) => {
|
|
853
853
|
let components
|
|
854
854
|
|
|
855
855
|
// example from RFC 6455, Sec 4.1
|
|
856
|
-
components =
|
|
856
|
+
components = fastURI.parse('wss://example.com/chat')
|
|
857
857
|
t.equal(components.error, undefined, 'error')
|
|
858
858
|
t.equal(components.scheme, 'wss', 'scheme')
|
|
859
859
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -865,7 +865,7 @@ if (URI.SCHEMES.wss) {
|
|
|
865
865
|
t.equal(components.resourceName, '/chat', 'resourceName')
|
|
866
866
|
t.equal(components.secure, true, 'secure')
|
|
867
867
|
|
|
868
|
-
components =
|
|
868
|
+
components = fastURI.parse('wss://example.com/foo?bar=baz')
|
|
869
869
|
t.equal(components.error, undefined, 'error')
|
|
870
870
|
t.equal(components.scheme, 'wss', 'scheme')
|
|
871
871
|
t.equal(components.userinfo, undefined, 'userinfo')
|
|
@@ -877,36 +877,36 @@ if (URI.SCHEMES.wss) {
|
|
|
877
877
|
t.equal(components.resourceName, '/foo?bar=baz', 'resourceName')
|
|
878
878
|
t.equal(components.secure, true, 'secure')
|
|
879
879
|
|
|
880
|
-
components =
|
|
880
|
+
components = fastURI.parse('wss://example.com/?bar=baz')
|
|
881
881
|
t.equal(components.resourceName, '/?bar=baz', 'resourceName')
|
|
882
882
|
|
|
883
883
|
t.end()
|
|
884
884
|
})
|
|
885
885
|
|
|
886
886
|
test('WSS Serialize', (t) => {
|
|
887
|
-
t.equal(
|
|
888
|
-
t.equal(
|
|
889
|
-
t.equal(
|
|
890
|
-
t.equal(
|
|
891
|
-
t.equal(
|
|
892
|
-
t.equal(
|
|
893
|
-
t.equal(
|
|
894
|
-
t.equal(
|
|
895
|
-
t.equal(
|
|
896
|
-
t.equal(
|
|
897
|
-
t.equal(
|
|
898
|
-
t.equal(
|
|
899
|
-
t.equal(
|
|
887
|
+
t.equal(fastURI.serialize({ scheme: 'wss' }), 'wss:')
|
|
888
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com' }), 'wss://example.com')
|
|
889
|
+
t.equal(fastURI.serialize({ scheme: 'wss', resourceName: '/' }), 'wss:')
|
|
890
|
+
t.equal(fastURI.serialize({ scheme: 'wss', resourceName: '/foo' }), 'wss:/foo')
|
|
891
|
+
t.equal(fastURI.serialize({ scheme: 'wss', resourceName: '/foo?bar' }), 'wss:/foo?bar')
|
|
892
|
+
t.equal(fastURI.serialize({ scheme: 'wss', secure: false }), 'ws:')
|
|
893
|
+
t.equal(fastURI.serialize({ scheme: 'wss', secure: true }), 'wss:')
|
|
894
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo' }), 'wss://example.com/foo')
|
|
895
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar' }), 'wss://example.com/foo?bar')
|
|
896
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', secure: false }), 'ws://example.com')
|
|
897
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', secure: true }), 'wss://example.com')
|
|
898
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
|
|
899
|
+
t.equal(fastURI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
|
|
900
900
|
t.end()
|
|
901
901
|
})
|
|
902
902
|
|
|
903
903
|
test('WSS Equal', (t) => {
|
|
904
|
-
t.equal(
|
|
904
|
+
t.equal(fastURI.equal('WSS://ABC.COM:443/chat#one', 'wss://abc.com/chat'), true)
|
|
905
905
|
t.end()
|
|
906
906
|
})
|
|
907
907
|
|
|
908
908
|
test('WSS Normalize', (t) => {
|
|
909
|
-
t.equal(
|
|
909
|
+
t.equal(fastURI.normalize('wss://example.com:443/foo#hash'), 'wss://example.com/foo')
|
|
910
910
|
t.end()
|
|
911
911
|
})
|
|
912
912
|
}
|