forked from Mirrors/doipjs
Throw error for invalid URI
This commit is contained in:
parent
7f24354c1d
commit
1230e5b9d8
2 changed files with 5 additions and 1 deletions
|
@ -16,7 +16,7 @@ const matchSp = (uri) => {
|
||||||
|
|
||||||
const verify = (uri, fingerprint, opts) => {
|
const verify = (uri, fingerprint, opts) => {
|
||||||
if (!validUrl.isUri(uri)) {
|
if (!validUrl.isUri(uri)) {
|
||||||
throw new Error('The provided URI was not valid')
|
throw new Error('Not a valid URI')
|
||||||
}
|
}
|
||||||
|
|
||||||
const spMatches = matchSp(uri)
|
const spMatches = matchSp(uri)
|
||||||
|
|
|
@ -37,6 +37,10 @@ describe('verify', () => {
|
||||||
expect(doipjs.verify).to.be.a('function')
|
expect(doipjs.verify).to.be.a('function')
|
||||||
expect(doipjs.verify).to.have.length(3)
|
expect(doipjs.verify).to.have.length(3)
|
||||||
})
|
})
|
||||||
|
it('should throw an error for non-valid URIs', () => {
|
||||||
|
expect(() => { doipjs.verify('noURI') }).to.throw('Not a valid URI')
|
||||||
|
expect(() => { doipjs.verify('domain.org') }).to.throw('Not a valid URI')
|
||||||
|
})
|
||||||
it('should match "dns:domain.org" to the DNS service provider', () => {
|
it('should match "dns:domain.org" to the DNS service provider', () => {
|
||||||
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.a('array')
|
||||||
|
|
Loading…
Reference in a new issue