Skip to content

Commit

Permalink
refactor: follow new linter rules from latest aegir
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jul 22, 2018
1 parent a793da7 commit db6cc3c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const fqdnProtocolMatch = 2
function isMultihash (hash) {
const formatted = convertToString(hash)
try {
const buffer = new Buffer(base58.decode(formatted))
const buffer = Buffer.from(base58.decode(formatted))
multihash.decode(buffer)
return true
} catch (e) {
Expand Down
7 changes: 2 additions & 5 deletions test/test-cid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe('ipfs cid', () => {
})

it('isIPFS.cid should match a valid CIDv0 (multihash) buffer', (done) => {
const actual = isIPFS.cid(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.cid(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(true)
done()
})

it('isIPFS.cid should not match a broken CIDv0 buffer', (done) => {
const actual = isIPFS.cid(new Buffer('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE70'))
const actual = isIPFS.cid(Buffer.from('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE70'))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -48,7 +48,6 @@ describe('ipfs cid', () => {
done()
})


it('isIPFS.cid should not match an invalid CID', (done) => {
const actual = isIPFS.cid('noop')
expect(actual).to.equal(false)
Expand All @@ -60,6 +59,4 @@ describe('ipfs cid', () => {
expect(actual).to.equal(false)
done()
})


})
4 changes: 0 additions & 4 deletions test/test-multibase.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-env mocha */
'use strict'

const base58btc = require('bs58')
const expect = require('chai').expect
const isIPFS = require('../src/index')

Expand Down Expand Up @@ -30,7 +29,6 @@ describe('ipfs base32cid', () => {
done()
})


it('isIPFS.base32cid should not match an invalid CID', (done) => {
const actual = isIPFS.base32cid('noop')
expect(actual).to.equal(false)
Expand All @@ -42,7 +40,6 @@ describe('ipfs base32cid', () => {
expect(actual).to.equal(false)
done()
})

})

describe('ipfs multibase', () => {
Expand All @@ -69,5 +66,4 @@ describe('ipfs multibase', () => {
expect(actual).to.equal(false)
done()
})

})
4 changes: 2 additions & 2 deletions test/test-multihash.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe('ipfs multihash', () => {
})

it('isIPFS.multihash should match a valid multihash buffer', (done) => {
const actual = isIPFS.multihash(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.multihash(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(true)
done()
})

it('isIPFS.multihash should not match a buffer', (done) => {
const actual = isIPFS.multihash(new Buffer('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE70'))
const actual = isIPFS.multihash(Buffer.from('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE70'))
expect(actual).to.equal(false)
done()
})
Expand Down
8 changes: 4 additions & 4 deletions test/test-path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ipfs path', () => {
})

it('isIPFS.ipfsPath should not match a buffer data type', (done) => {
const actual = isIPFS.ipfsPath(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.ipfsPath(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('ipfs path', () => {
})

it('isIPFS.ipnsPath should not match a buffer data type', (done) => {
const actual = isIPFS.ipnsPath(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.ipnsPath(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('ipfs path', () => {
})

it('isIPFS.path should not match a buffer data type', (done) => {
const actual = isIPFS.path(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.path(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('ipfs path', () => {
})

it('isIPFS.urlOrPath should not match a buffer data type', (done) => {
const actual = isIPFS.ipfsPath(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.ipfsPath(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down
7 changes: 3 additions & 4 deletions test/test-subdomain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('ipfs subdomain', () => {
})

it('isIPFS.ipfsSubdomain should not match a buffer data type', (done) => {
const actual = isIPFS.ipfsSubdomain(new Buffer(base58.decode('QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR')))
const actual = isIPFS.ipfsSubdomain(Buffer.from(base58.decode('QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('ipfs subdomain', () => {
})

it('isIPFS.ipnsSubdomain should not match a buffer data type', (done) => {
const actual = isIPFS.ipnsSubdomain(new Buffer(base58.decode('QmNQuBJ8tg4QN6mSLXHekxBbcToPwKxamWNrDdEugxMTDd')))
const actual = isIPFS.ipnsSubdomain(Buffer.from(base58.decode('QmNQuBJ8tg4QN6mSLXHekxBbcToPwKxamWNrDdEugxMTDd')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('ipfs subdomain', () => {
})

it('isIPFS.subdomain should not match a buffer data type', (done) => {
const actual = isIPFS.subdomain(new Buffer(base58.decode('QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR')))
const actual = isIPFS.subdomain(Buffer.from(base58.decode('QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR')))
expect(actual).to.equal(false)
done()
})
Expand All @@ -142,5 +142,4 @@ describe('ipfs subdomain', () => {
expect(actual).to.equal(false)
done()
})

})
6 changes: 3 additions & 3 deletions test/test-url.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ipfs url', () => {
})

it('isIPFS.ipfsUrl should not match a buffer input', (done) => {
const actual = isIPFS.ipfsUrl(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.ipfsUrl(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('ipfs url', () => {
})

it('isIPFS.ipnsUrl should not match a buffer input', (done) => {
const actual = isIPFS.ipnsUrl(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.ipnsUrl(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('ipfs url', () => {
})

it('isIPFS.url should not match a buffer input', (done) => {
const actual = isIPFS.url(new Buffer(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
const actual = isIPFS.url(Buffer.from(base58.decode('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o')))
expect(actual).to.equal(false)
done()
})
Expand Down

0 comments on commit db6cc3c

Please sign in to comment.