Skip to content

Commit fb97e30

Browse files
authored
docs: update readme toc (#56)
1 parent eae61c3 commit fb97e30

File tree

1 file changed

+26
-51
lines changed

1 file changed

+26
-51
lines changed

README.md

+26-51
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
88
## Table of contents <!-- omit in toc -->
99

10-
- - [Install](#install)
11-
- [Lead Maintainer](#lead-maintainer)
12-
- [Browser: Browserify, Webpack, other bundlers](#browser-browserify-webpack-other-bundlers)
13-
- [In the Browser through `<script>` tag](#in-the-browser-through-script-tag)
10+
- [Install](#install)
1411
- [Usage](#usage)
1512
- [API](#api)
1613
- [Content Identifiers](#content-identifiers)
@@ -34,38 +31,16 @@
3431
- [Multiaddrs](#multiaddrs)
3532
- [`isIPFS.multiaddr(addr)`](#isipfsmultiaddraddr)
3633
- [`isIPFS.peerMultiaddr(addr)`](#isipfspeermultiaddraddr)
37-
- [License](#license)
38-
- [Contribute](#contribute)
34+
- [License](#license)
35+
- [Contribute](#contribute)
3936

4037
## Install
4138

4239
```console
4340
$ npm i is-ipfs
4441
```
4542

46-
```bash
47-
$ npm install --save is-ipfs
48-
```
49-
50-
### Browser: Browserify, Webpack, other bundlers
51-
52-
The code published to npm that gets loaded on require is in fact an ES5 transpiled version with the right shims added. This means that you can require it and use with your favorite bundler without having to adjust asset management process.
53-
54-
```js
55-
import * as isIPFS from 'is-ipfs'
56-
```
57-
58-
### In the Browser through `<script>` tag
59-
60-
Loading this module through a script tag will make the `IsIpfs` obj available in the global namespace.
61-
62-
```html
63-
<script src="https://unpkg.com/is-ipfs/dist/index.min.js"></script>
64-
<!-- OR -->
65-
<script src="https://unpkg.com/is-ipfs/dist/index.js"></script>
66-
```
67-
68-
# Usage
43+
## Usage
6944

7045
```javascript
7146
import * as isIPFS from 'is-ipfs'
@@ -149,7 +124,7 @@ isIPFS.peerMultiaddr('/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQ
149124
isIPFS.peerMultiaddr('/ip4/127.0.0.1/udp/1234') // false (key missing)
150125
```
151126

152-
# API
127+
## API
153128

154129
A suite of util methods that provides efficient validation.
155130

@@ -158,71 +133,71 @@ Detection of IPFS Paths and identifiers in URLs is a two-stage process:
158133
1. `pathPattern`/`pathGatewayPattern`/`subdomainGatewayPattern` regex is applied to quickly identify potential candidates
159134
2. proper CID validation is applied to remove false-positives
160135

161-
## Content Identifiers
136+
### Content Identifiers
162137

163-
### `isIPFS.multihash(hash)`
138+
#### `isIPFS.multihash(hash)`
164139

165140
Returns `true` if the provided string or `Uint8Array` is a valid `multihash` or `false` otherwise.
166141

167-
### `isIPFS.cid(hash)`
142+
#### `isIPFS.cid(hash)`
168143

169144
Returns `true` if the provided string, `Uint8Array` or [`CID`](https://github.com/multiformats/js-multiformats/#readme) object represents a valid [CID](https://docs.ipfs.io/guides/concepts/cid/) or `false` otherwise.
170145

171-
### `isIPFS.base32cid(hash)`
146+
#### `isIPFS.base32cid(hash)`
172147

173148
Returns `true` if the provided string is a valid `CID` in Base32 encoding or `false` otherwise.
174149

175-
## URLs
150+
### URLs
176151

177-
### `isIPFS.url(url)`
152+
#### `isIPFS.url(url)`
178153

179154
Returns `true` if the provided string is a valid IPFS or IPNS url or `false` otherwise.
180155

181-
### `isIPFS.ipfsUrl(url)`
156+
#### `isIPFS.ipfsUrl(url)`
182157

183158
Returns `true` if the provided string is a valid IPFS url or `false` otherwise.
184159

185-
### `isIPFS.ipnsUrl(url)`
160+
#### `isIPFS.ipnsUrl(url)`
186161

187162
Returns `true` if the provided string is a valid IPNS url or `false` otherwise.
188163

189-
## Paths
164+
### Paths
190165

191166
Standalone validation of IPFS Paths: `/ip(f|n)s/<cid>/..`
192167

193-
### `isIPFS.path(path)`
168+
#### `isIPFS.path(path)`
194169

195170
Returns `true` if the provided string is a valid IPFS or IPNS path or `false` otherwise.
196171

197-
### `isIPFS.urlOrPath(path)`
172+
#### `isIPFS.urlOrPath(path)`
198173

199174
Returns `true` if the provided string is a valid IPFS or IPNS url or path or `false` otherwise.
200175

201-
### `isIPFS.ipfsPath(path)`
176+
#### `isIPFS.ipfsPath(path)`
202177

203178
Returns `true` if the provided string is a valid IPFS path or `false` otherwise.
204179

205-
### `isIPFS.ipnsPath(path)`
180+
#### `isIPFS.ipnsPath(path)`
206181

207182
Returns `true` if the provided string is a valid IPNS path or `false` otherwise.
208183

209-
### `isIPFS.cidPath(path)`
184+
#### `isIPFS.cidPath(path)`
210185

211186
Returns `true` if the provided string is a valid "CID path" (IPFS path without `/ipfs/` prefix) or `false` otherwise.
212187

213-
## Subdomains
188+
### Subdomains
214189

215190
Validated subdomain convention: `cidv1b32.ip(f|n)s.domain.tld`
216191

217-
### `isIPFS.subdomain(url)`
192+
#### `isIPFS.subdomain(url)`
218193

219194
Returns `true` if the provided `url` string includes a valid IPFS, looks like IPNS/DNSLink subdomain or `false` otherwise.
220195

221-
### `isIPFS.ipfsSubdomain(url)`
196+
#### `isIPFS.ipfsSubdomain(url)`
222197

223198
Returns `true` if the provided `url` string includes a valid IPFS subdomain (case-insensitive CIDv1) or `false` otherwise.
224199

225-
### `isIPFS.ipnsSubdomain(url)`
200+
#### `isIPFS.ipnsSubdomain(url)`
226201

227202
Returns `true` if the provided `url` string looks like a valid IPNS subdomain
228203
(CIDv1 with `libp2p-key` multicodec or something that looks like a FQDN, for example `en.wikipedia-on-ipfs.org.ipns.localhost:8080`) or `false`
@@ -235,17 +210,17 @@ return false-positives:
235210
- To ensure IPNS record exists, make a call to `/api/v0/name/resolve?arg=<ipnsid>`
236211
- To ensure DNSLink exists, make a call to `/api/v0/dns?arg=<fqdn>`
237212

238-
## Multiaddrs
213+
### Multiaddrs
239214

240215
Below methods provide basic detection of [multiaddr](https://github.com/multiformats/multiaddr)s: composable and future-proof network addresses.
241216

242217
Complex validation of multiaddr can be built using `isIPFS.multiaddr` and [`mafmt`](https://github.com/multiformats/js-mafmt) library.
243218

244-
### `isIPFS.multiaddr(addr)`
219+
#### `isIPFS.multiaddr(addr)`
245220

246221
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid multiaddr or `false` otherwise.
247222

248-
### `isIPFS.peerMultiaddr(addr)`
223+
#### `isIPFS.peerMultiaddr(addr)`
249224

250225
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid libp2p peer multiaddr (matching [`P2P` format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or `false` otherwise.
251226

0 commit comments

Comments
 (0)