function parseIpfsPath (ipfsPath) {
  const invalidPathErr = new Error('invalid ipfs ref path')
  ipfsPath = ipfsPath.replace(/^\/ipfs\//, '')
  const matched = ipfsPath.match(/([^/]+(?:\/[^/]+)*)\/?$/)
  if (!matched) {
    throw invalidPathErr
  }

  const [hash, ...links] = matched[1].split('/')

  // check that a CID can be constructed with the hash
  if (isIpfs.cid(hash)) {
    return { hash, links }
  } else {
    throw invalidPathErr
  }
}
function parseIpfsPath (ipfsPath) {
  const invalidPathErr = new Error('invalid ipfs ref path')
  ipfsPath = ipfsPath.replace(/^\/ipfs\//, '')
  const matched = ipfsPath.match(/([^/]+(?:\/[^/]+)*)\/?$/)
  if (!matched) {
    throw invalidPathErr
  }

  const [hash, ...links] = matched[1].split('/')

  // check that a CID can be constructed with the hash
  if (isIpfs.cid(hash)) {
    return { hash, links }
  } else {
    throw invalidPathErr
  }
}
function parseIpfsPath ( ipfsPath ) { const invalidPathErr = new Error ( 'invalid ipfs ref path' ) ipfsPath = ipfsPath . replace ( / ^\/ipfs\/ / , '' ) const matched = ipfsPath . match ( / ([^/]+(?:\/[^/]+)*)\/?$ / ) if ( ! matched ) { throw invalidPathErr } const [ hash , ... links ] = matched [ 1 ] . split ( '/' ) // check that a CID can be constructed with the hash if ( isIpfs . cid ( hash ) ) { return { hash , links } } else { throw invalidPathErr } }
Break an ipfs-path down into it's hash and an array of links.

examples:
b58Hash -> { hash: 'b58Hash', links: [] }
b58Hash/mercury/venus -> { hash: 'b58Hash', links: ['mercury', 'venus']}
/ipfs/b58Hash/links/by/name -> { hash: 'b58Hash', links: ['links', 'by', 'name'] }

@param  {String} ipfsPath An ipfs-path
@return {Object}            { hash: base58 string, links: [string], ?err: Error }
@throws on an invalid @param ipfsPath
Break an ipfs - path down into it s hash and an array of links .
Parse the ipfs ref path