Name: dweb-path
Owner: TABLEFLIP
Description: Utility for parsing, validating and inspecting dweb paths
Created: 2018-05-02 12:37:37.0
Updated: 2018-05-02 13:10:49.0
Pushed: 2018-05-02 13:10:47.0
Homepage: null
Size: 61
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Utility for parsing, validating and inspecting dweb paths
Currently supported path types:
install dweb-path
t dwebPath = require('dweb-path')
ole.log(dwebPath.ipfs('/ipfs/zdpuArHMUAYi3VtD3f7iSkXxYK9xo687SoNf5stAQNCMzd77k/gif'))
ns: 'ipfs',
hash: 'zdpuArHMUAYi3VtD3f7iSkXxYK9xo687SoNf5stAQNCMzd77k',
path: '/gif'
dwebPath.ipfs(input): { ns, hash, path, toString }
Parse an input
as an IPFS path and return an object of it's component parts.
Where input
can be:
String
/ipfs/Qmf1JJkBEk7nSdYZJqumJVREE1bMZS7uMm6DQFxRxWShwD/file.txt
/ipns/yourdomain.name/file.txt
Qmf1JJkBEk7nSdYZJqumJVREE1bMZS7uMm6DQFxRxWShwD
Qmf1JJkBEk7nSdYZJqumJVREE1bMZS7uMm6DQFxRxWShwD/file.txt
CID
- a CID instanceBuffer
- a Buffer CIDNote that for string values, a missing leading forward slash and/or namespace are also accepted as valid paths.
The return value is an object with the following properties:
ns: String
- the namespace of the path e.g. “ipfs” or “ipns”hash: String
- the content identifier (the bit after the namespace)path: String
- the path component of the dweb path (the bit after the hash)toString: Function
- (non-enumerable) call this to get the normalized dweb path (missing namespace added and trailing slash removed) as a stringtoJSON: Function
- (non-enumerable) same return value as toString
hash
will be encoded as “base58btc” and ns
set to “ipfs”hash
will be the domain nameFeel free to dive in! Open an issue or submit PRs.
MIT © Alan Shaw