tableflip/dweb-path

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

dweb-path

Build Status dependencies Status JavaScript Style Guide

Utility for parsing, validating and inspecting dweb paths

Currently supported path types:

Install
install dweb-path
Usage
With IPFS path
t dwebPath = require('dweb-path')
ole.log(dwebPath.ipfs('/ipfs/zdpuArHMUAYi3VtD3f7iSkXxYK9xo687SoNf5stAQNCMzd77k/gif'))


 ns: 'ipfs',
 hash: 'zdpuArHMUAYi3VtD3f7iSkXxYK9xo687SoNf5stAQNCMzd77k',
 path: '/gif'

API
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:

Note 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:

Notes
  1. When passing a CID instance or a buffer, hash will be encoded as “base58btc” and ns set to “ipfs”
  2. When passing an IPNS path with a domain name, hash will be the domain name
Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.