You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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*asisIPFSfrom'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.
A suite of util methods that provides efficient validation.
155
130
@@ -158,71 +133,71 @@ Detection of IPFS Paths and identifiers in URLs is a two-stage process:
158
133
1.`pathPattern`/`pathGatewayPattern`/`subdomainGatewayPattern` regex is applied to quickly identify potential candidates
159
134
2. proper CID validation is applied to remove false-positives
160
135
161
-
## Content Identifiers
136
+
###Content Identifiers
162
137
163
-
### `isIPFS.multihash(hash)`
138
+
####`isIPFS.multihash(hash)`
164
139
165
140
Returns `true` if the provided string or `Uint8Array` is a valid `multihash` or `false` otherwise.
166
141
167
-
### `isIPFS.cid(hash)`
142
+
####`isIPFS.cid(hash)`
168
143
169
144
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.
170
145
171
-
### `isIPFS.base32cid(hash)`
146
+
####`isIPFS.base32cid(hash)`
172
147
173
148
Returns `true` if the provided string is a valid `CID` in Base32 encoding or `false` otherwise.
174
149
175
-
## URLs
150
+
###URLs
176
151
177
-
### `isIPFS.url(url)`
152
+
####`isIPFS.url(url)`
178
153
179
154
Returns `true` if the provided string is a valid IPFS or IPNS url or `false` otherwise.
180
155
181
-
### `isIPFS.ipfsUrl(url)`
156
+
####`isIPFS.ipfsUrl(url)`
182
157
183
158
Returns `true` if the provided string is a valid IPFS url or `false` otherwise.
184
159
185
-
### `isIPFS.ipnsUrl(url)`
160
+
####`isIPFS.ipnsUrl(url)`
186
161
187
162
Returns `true` if the provided string is a valid IPNS url or `false` otherwise.
188
163
189
-
## Paths
164
+
###Paths
190
165
191
166
Standalone validation of IPFS Paths: `/ip(f|n)s/<cid>/..`
192
167
193
-
### `isIPFS.path(path)`
168
+
####`isIPFS.path(path)`
194
169
195
170
Returns `true` if the provided string is a valid IPFS or IPNS path or `false` otherwise.
196
171
197
-
### `isIPFS.urlOrPath(path)`
172
+
####`isIPFS.urlOrPath(path)`
198
173
199
174
Returns `true` if the provided string is a valid IPFS or IPNS url or path or `false` otherwise.
200
175
201
-
### `isIPFS.ipfsPath(path)`
176
+
####`isIPFS.ipfsPath(path)`
202
177
203
178
Returns `true` if the provided string is a valid IPFS path or `false` otherwise.
204
179
205
-
### `isIPFS.ipnsPath(path)`
180
+
####`isIPFS.ipnsPath(path)`
206
181
207
182
Returns `true` if the provided string is a valid IPNS path or `false` otherwise.
208
183
209
-
### `isIPFS.cidPath(path)`
184
+
####`isIPFS.cidPath(path)`
210
185
211
186
Returns `true` if the provided string is a valid "CID path" (IPFS path without `/ipfs/` prefix) or `false` otherwise.
Returns `true` if the provided `url` string includes a valid IPFS, looks like IPNS/DNSLink subdomain or `false` otherwise.
220
195
221
-
### `isIPFS.ipfsSubdomain(url)`
196
+
####`isIPFS.ipfsSubdomain(url)`
222
197
223
198
Returns `true` if the provided `url` string includes a valid IPFS subdomain (case-insensitive CIDv1) or `false` otherwise.
224
199
225
-
### `isIPFS.ipnsSubdomain(url)`
200
+
####`isIPFS.ipnsSubdomain(url)`
226
201
227
202
Returns `true` if the provided `url` string looks like a valid IPNS subdomain
228
203
(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:
235
210
- To ensure IPNS record exists, make a call to `/api/v0/name/resolve?arg=<ipnsid>`
236
211
- To ensure DNSLink exists, make a call to `/api/v0/dns?arg=<fqdn>`
237
212
238
-
## Multiaddrs
213
+
###Multiaddrs
239
214
240
215
Below methods provide basic detection of [multiaddr](https://github.com/multiformats/multiaddr)s: composable and future-proof network addresses.
241
216
242
217
Complex validation of multiaddr can be built using `isIPFS.multiaddr` and [`mafmt`](https://github.com/multiformats/js-mafmt) library.
243
218
244
-
### `isIPFS.multiaddr(addr)`
219
+
####`isIPFS.multiaddr(addr)`
245
220
246
221
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid multiaddr or `false` otherwise.
247
222
248
-
### `isIPFS.peerMultiaddr(addr)`
223
+
####`isIPFS.peerMultiaddr(addr)`
249
224
250
225
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.
0 commit comments