Skip to content

Commit 69890e2

Browse files
deps(dev): bump aegir from 40.0.13 to 41.1.8 (#18)
Bumps [aegir](https://github.com/ipfs/aegir) from 40.0.13 to 41.1.8. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](ipfs/aegir@v40.0.13...v41.1.8) --- updated-dependencies: - dependency-name: aegir dependency-type: direct:development update-type: version-update:semver-major ... --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain <[email protected]>
1 parent 81e4c45 commit 69890e2

File tree

5 files changed

+65
-17
lines changed

5 files changed

+65
-17
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Semantic PR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
uses: pl-strflt/.github/.github/workflows/[email protected]

.github/workflows/stale.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close and mark stale issue
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
stale:
13+
uses: pl-strflt/.github/.github/workflows/[email protected]

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,66 @@
1-
# @multiformats/multiaddr-matcher <!-- omit in toc -->
2-
31
[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)
42
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiaddr-matcher.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiaddr-matcher)
53
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-multiaddr-matcher/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/multiformats/js-multiaddr-matcher/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
64

75
> Match different multiaddr formats
86
9-
## Table of contents <!-- omit in toc -->
7+
# About
8+
9+
This module exports various matchers that can be used to infer the type of a
10+
passed multiaddr.
11+
12+
## Example
13+
14+
```ts
15+
import { multiaddr } from '@multiformats/multiaddr'
16+
import { DNS } from '@multiformats/multiaddr-matcher'
17+
18+
const ma = multiaddr('/dnsaddr/example.org')
19+
20+
DNS.matches(ma) // true - this is a multiaddr with a DNS address at the start
21+
```
22+
23+
## Example
24+
25+
The default matching behaviour ignores any subsequent tuples in the multiaddr.
26+
If you want stricter matching you can use `.exactMatch`:
1027

11-
- [Install](#install)
12-
- [Browser `<script>` tag](#browser-script-tag)
13-
- [API Docs](#api-docs)
14-
- [License](#license)
15-
- [Contribution](#contribution)
28+
```ts
29+
import { multiaddr } from '@multiformats/multiaddr'
30+
import { DNS, Circuit } from '@multiformats/multiaddr-matcher'
31+
32+
const ma = multiaddr('/dnsaddr/example.org/p2p/QmFoo/p2p-circuit/p2p/QmBar')
33+
34+
DNS.exactMatch(ma) // false - this address has extra tuples after the DNS component
35+
Circuit.matches(ma) // true
36+
Circuit.exactMatch(ma) // true - the extra tuples are circuit relay related
37+
```
1638

17-
## Install
39+
# Install
1840

1941
```console
2042
$ npm i @multiformats/multiaddr-matcher
2143
```
2244

23-
### Browser `<script>` tag
45+
## Browser `<script>` tag
2446

2547
Loading this module through a script tag will make it's exports available as `MultiformatsMultiaddrMatcher` in the global namespace.
2648

2749
```html
2850
<script src="https://unpkg.com/@multiformats/multiaddr-matcher/dist/index.min.js"></script>
2951
```
3052

31-
## API Docs
53+
# API Docs
3254

3355
- <https://multiformats.github.io/js-multiaddr-matcher>
3456

35-
## License
57+
# License
3658

3759
Licensed under either of
3860

3961
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
4062
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
4163

42-
## Contribution
64+
# Contribution
4365

4466
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"eslintConfig": {
3232
"extends": "ipfs",
3333
"parserOptions": {
34+
"project": true,
3435
"sourceType": "module"
3536
}
3637
},
@@ -141,6 +142,6 @@
141142
"multiformats": "^12.0.1"
142143
},
143144
"devDependencies": {
144-
"aegir": "^40.0.8"
145+
"aegir": "^41.1.8"
145146
}
146147
}

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const toParts = (ma: Multiaddr): string[] => {
4949
* false or returns a sublist of unmatched components
5050
*/
5151
interface Matcher {
52-
match: (parts: string[]) => string[] | false
52+
match(parts: string[]): string[] | false
5353
pattern: string
5454
}
5555

@@ -255,13 +255,13 @@ export interface MultiaddrMatcher {
255255
* Returns true if the passed multiaddr can be treated as this type of
256256
* multiaddr
257257
*/
258-
matches: (ma: Multiaddr) => boolean
258+
matches(ma: Multiaddr): boolean
259259

260260
/**
261261
* Returns true if the passed multiaddr terminates as this type of
262262
* multiaddr
263263
*/
264-
exactMatch: (ma: Multiaddr) => boolean
264+
exactMatch(ma: Multiaddr): boolean
265265
}
266266

267267
/**

0 commit comments

Comments
 (0)