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+
17## [ 1.4.0] ( https://github.com/multiformats/js-multiaddr-matcher/compare/v1.3.0...v1.4.0 ) (2024-10-28)
28
39### Features
Original file line number Diff line number Diff line change 11{
22 "name" : " @multiformats/multiaddr-matcher" ,
3- "version" : " 1.4.0 " ,
3+ "version" : " 1.4.1 " ,
44 "description" : " Match different multiaddr formats" ,
55 "license" : " Apache-2.0 OR MIT" ,
66 "homepage" : " https://github.com/multiformats/js-multiaddr-matcher#readme" ,
166166 "multiformats" : " ^13.0.0"
167167 },
168168 "devDependencies" : {
169- "aegir" : " ^44.1 .1"
169+ "aegir" : " ^45.0 .1"
170170 }
171171}
Original file line number Diff line number Diff line change @@ -461,6 +461,23 @@ const _HTTPS = or(
461461 */
462462export const HTTPS = fmt ( _HTTPS )
463463
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+
464481const _Unix = or (
465482 and ( literal ( 'unix' ) , string ( ) , optional ( peerId ( ) ) )
466483)
Original file line number Diff line number Diff line change @@ -309,6 +309,20 @@ describe('multiaddr matcher', () => {
309309 '/ip4/0.0.0.0/udp/80/http'
310310 ]
311311
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+
312326 const exactUnix = [
313327 '/unix/%2Fpath%2Fto%2Funix.socket' ,
314328 '/unix/%2Fpath%2Fto%2Funix.socket/p2p/12D3KooWQF6Q3i1QkziJQ9mkNNcyFD8GPQz6R6oEvT75wgsVXm4v'
@@ -430,6 +444,12 @@ describe('multiaddr matcher', () => {
430444 assertMismatches ( mafmt . HTTPS , badHTTPS )
431445 } )
432446
447+ it ( 'Memory addresses' , ( ) => {
448+ assertMatches ( mafmt . Memory , goodMemory )
449+ assertExactMatches ( mafmt . Memory , exactMemory )
450+ assertMismatches ( mafmt . Memory , badMemory )
451+ } )
452+
433453 it ( 'Unix addresses' , ( ) => {
434454 assertMatches ( mafmt . Unix , goodUnix )
435455 assertExactMatches ( mafmt . Unix , exactUnix )
You can’t perform that action at this time.
0 commit comments