How to use the mafmt.IPFS function in mafmt

To help you get started, we’ve selected a few mafmt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / is-ipfs / src / index.js View on Github external
function isPeerMultiaddr (input) {
  if (!isMultiaddr(input)) return false
  if (input instanceof Buffer) {
    // mafmt does not support Buffer input
    input = new Multiaddr(input)
  }
  return mafmt.IPFS.matches(input)
}
github libp2p / js-libp2p-bootstrap / test / bootstrap.spec.js View on Github external
r.once('peer', (peer) => {
        const peerList = peer.multiaddrs.toArray()
        expect(peerList.length).to.eq(1)
        expect(mafmt.IPFS.matches(peerList[0].toString())).equals(true)
        resolve()
      })
    })
github ipfs / js-ipfs / src / cli / commands / swarm / peers.js View on Github external
result.forEach((item) => {
        let ma = multiaddr(item.addr.toString())
        if (!mafmt.IPFS.matches(ma)) {
          ma = ma.encapsulate('/ipfs/' + item.peer.toB58String())
        }
        const addr = ma.toString()
        argv.print(addr)
      })
    })())
github ipfs / js-ipfs / src / core / components / bootstrap.js View on Github external
'use strict'

const defaultConfig = require('../runtime/config-nodejs.js')
const isMultiaddr = require('mafmt').IPFS.matches
const callbackify = require('callbackify')

function isValidMultiaddr (ma) {
  try {
    return isMultiaddr(ma)
  } catch (err) {
    return false
  }
}

function invalidMultiaddrError (ma) {
  return new Error(`${ma} is not a valid Multiaddr`)
}

module.exports = function bootstrap (self) {
  return {
github ipfs / js-ipfs / src / core / config.js View on Github external
    'multiaddr-ipfs': v => mafmt.IPFS.matches(v) ? true : 'multiaddr IPFS invalid'
  }

mafmt

A multiaddr validator

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis