From 1230e5b9d8958f1e956c1f2fb40f812209729c0d Mon Sep 17 00:00:00 2001
From: Yarmo Mackenbach <yarmo@yarmo.eu>
Date: Sat, 24 Oct 2020 11:56:30 +0200
Subject: [PATCH] Throw error for invalid URI

---
 src/index.js        | 2 +-
 test/verify.test.js | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/index.js b/src/index.js
index 4a4a865..cc259ad 100644
--- a/src/index.js
+++ b/src/index.js
@@ -16,7 +16,7 @@ const matchSp = (uri) => {
 
 const verify = (uri, fingerprint, opts) => {
   if (!validUrl.isUri(uri)) {
-    throw new Error('The provided URI was not valid')
+    throw new Error('Not a valid URI')
   }
 
   const spMatches = matchSp(uri)
diff --git a/test/verify.test.js b/test/verify.test.js
index 3194f7e..183cc38 100644
--- a/test/verify.test.js
+++ b/test/verify.test.js
@@ -37,6 +37,10 @@ describe('verify', () => {
     expect(doipjs.verify).to.be.a('function')
     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', () => {
     const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
     expect(matches).to.be.a('array')