@@ -255,6 +255,47 @@ describe('multiaddr matcher', () => {
255
255
'/unix/var/log'
256
256
]
257
257
258
+ const exactHTTP = [
259
+ '/ip4/0.0.0.0/tcp/80/http' ,
260
+ '/ip6/fc00::/tcp/80/http' ,
261
+ '/dns4/example.org/tcp/80/http' ,
262
+ '/dns6/example.org/tcp/80/http' ,
263
+ '/dnsaddr/example.org/tcp/80/http' ,
264
+ '/dns/example.org/tcp/7777/http' ,
265
+ '/dns/example.org/tcp/7777/http/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
266
+ ]
267
+
268
+ const goodHTTP = [
269
+ ...exactHTTP
270
+ ]
271
+
272
+ const badHTTP = [
273
+ '/ip4/0.0.0.0/udp/80/http'
274
+ ]
275
+
276
+ const exactHTTPS = [
277
+ '/ip4/0.0.0.0/tcp/0/https' ,
278
+ '/ip6/fc00::/tcp/0/https' ,
279
+ '/dns4/example.org/tcp/80/https' ,
280
+ '/dns6/example.org/tcp/80/https' ,
281
+ '/dnsaddr/example.org/tcp/80/https' ,
282
+ '/dns/example.org/tcp/7777/https' ,
283
+ '/dns4/example.org/tcp/443/http' ,
284
+ '/dns6/example.org/tcp/443/http' ,
285
+ '/dnsaddr/example.org/tcp/443/http' ,
286
+ '/dns/example.org/tcp/443/http' ,
287
+ '/dns4/example.org/tls/http' ,
288
+ '/dns/example.org/tls/http/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
289
+ ]
290
+
291
+ const goodHTTPS = [
292
+ ...exactHTTPS
293
+ ]
294
+
295
+ const badHTTPS = [
296
+ '/ip4/0.0.0.0/udp/80/http'
297
+ ]
298
+
258
299
function assertMatches ( p : MultiaddrMatcher , ...tests : string [ ] [ ] ) : void {
259
300
tests . forEach ( ( test ) => {
260
301
test . forEach ( ( testcase ) => {
@@ -350,4 +391,16 @@ describe('multiaddr matcher', () => {
350
391
assertExactMatches ( mafmt . IP_OR_DOMAIN , exactIPorDomain )
351
392
assertMismatches ( mafmt . IP_OR_DOMAIN , badIPorDomain )
352
393
} )
394
+
395
+ it ( 'HTTP addresses' , ( ) => {
396
+ assertMatches ( mafmt . HTTP , goodHTTP )
397
+ assertExactMatches ( mafmt . HTTP , exactHTTP )
398
+ assertMismatches ( mafmt . HTTP , badHTTP )
399
+ } )
400
+
401
+ it ( 'HTTPS addresses' , ( ) => {
402
+ assertMatches ( mafmt . HTTPS , goodHTTPS )
403
+ assertExactMatches ( mafmt . HTTPS , exactHTTPS )
404
+ assertMismatches ( mafmt . HTTPS , badHTTPS )
405
+ } )
353
406
} )
0 commit comments