File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## [ 1.4.1] ( https://github.com/multiformats/js-multiaddr-matcher/compare/v1.4.0...v1.4.1 ) (2024-11-04)
2
+
3
+ ### Dependencies
4
+
5
+ * ** dev:** bump aegir from 44.1.4 to 45.0.1 ([ #40 ] ( https://github.com/multiformats/js-multiaddr-matcher/issues/40 ) ) ([ 443cd68] ( https://github.com/multiformats/js-multiaddr-matcher/commit/443cd6841c6623c6e2dc0dc7a83108f1d3dc4a0d ) )
6
+
1
7
## [ 1.4.0] ( https://github.com/multiformats/js-multiaddr-matcher/compare/v1.3.0...v1.4.0 ) (2024-10-28)
2
8
3
9
### Features
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @multiformats/multiaddr-matcher" ,
3
- "version" : " 1.4.0 " ,
3
+ "version" : " 1.4.1 " ,
4
4
"description" : " Match different multiaddr formats" ,
5
5
"license" : " Apache-2.0 OR MIT" ,
6
6
"homepage" : " https://github.com/multiformats/js-multiaddr-matcher#readme" ,
166
166
"multiformats" : " ^13.0.0"
167
167
},
168
168
"devDependencies" : {
169
- "aegir" : " ^44.1 .1"
169
+ "aegir" : " ^45.0 .1"
170
170
}
171
171
}
Original file line number Diff line number Diff line change @@ -461,6 +461,23 @@ const _HTTPS = or(
461
461
*/
462
462
export const HTTPS = fmt ( _HTTPS )
463
463
464
+ const _Memory = or (
465
+ and ( literal ( 'memory' ) , string ( ) , optional ( peerId ( ) ) )
466
+ )
467
+
468
+ /**
469
+ * Matches Memory addresses
470
+ *
471
+ * @example
472
+ *
473
+ * ```ts
474
+ * import { Memory } from '@multiformats/multiaddr-matcher'
475
+ *
476
+ * Memory.matches(multiaddr('/memory/0xDEADBEEF')) // true
477
+ * ```
478
+ */
479
+ export const Memory = fmt ( _Memory )
480
+
464
481
const _Unix = or (
465
482
and ( literal ( 'unix' ) , string ( ) , optional ( peerId ( ) ) )
466
483
)
Original file line number Diff line number Diff line change @@ -309,6 +309,20 @@ describe('multiaddr matcher', () => {
309
309
'/ip4/0.0.0.0/udp/80/http'
310
310
]
311
311
312
+ const exactMemory = [
313
+ '/memory/0xDEADBEEF' ,
314
+ '/memory/0xDEADBEEF/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
315
+ ]
316
+
317
+ const goodMemory = [
318
+ ...exactMemory ,
319
+ '/memory/0xDEADBEEF/webrtc/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
320
+ ]
321
+
322
+ const badMemory = [
323
+ '/ip4/0.0.0.0/udp/80/http'
324
+ ]
325
+
312
326
const exactUnix = [
313
327
'/unix/%2Fpath%2Fto%2Funix.socket' ,
314
328
'/unix/%2Fpath%2Fto%2Funix.socket/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
@@ -430,6 +444,12 @@ describe('multiaddr matcher', () => {
430
444
assertMismatches ( mafmt . HTTPS , badHTTPS )
431
445
} )
432
446
447
+ it ( 'Memory addresses' , ( ) => {
448
+ assertMatches ( mafmt . Memory , goodMemory )
449
+ assertExactMatches ( mafmt . Memory , exactMemory )
450
+ assertMismatches ( mafmt . Memory , badMemory )
451
+ } )
452
+
433
453
it ( 'Unix addresses' , ( ) => {
434
454
assertMatches ( mafmt . Unix , goodUnix )
435
455
assertExactMatches ( mafmt . Unix , exactUnix )
You can’t perform that action at this time.
0 commit comments