Add URI validation

This commit is contained in:
Yarmo Mackenbach 2020-10-24 11:19:35 +02:00
parent cdbb0b1ef1
commit b78d7a7ce9
3 changed files with 23 additions and 3 deletions

13
package-lock.json generated
View file

@ -7,6 +7,9 @@
"": {
"version": "0.1.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"valid-url": "^1.0.9"
},
"devDependencies": {
"chai": "^4.2.0",
"license-check-and-add": "^3.0.4",
@ -1462,6 +1465,11 @@
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true
},
"node_modules/valid-url": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz",
"integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA="
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -2769,6 +2777,11 @@
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true
},
"valid-url": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz",
"integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View file

@ -3,7 +3,9 @@
"version": "0.1.0",
"description": "Decentralized OpenPGP Identity Proofs library in node",
"main": "src/index.js",
"dependencies": {},
"dependencies": {
"valid-url": "^1.0.9"
},
"devDependencies": {
"chai": "^4.2.0",
"license-check-and-add": "^3.0.4",

View file

@ -1,7 +1,12 @@
const verify = (url, fingerprint, opts) => {
const validUrl = require('valid-url')
const serviceprovidersList = require('./serviceproviders').serviceprovidersList
const verify = (uri, fingerprint, opts) => {
if !(validUrl.isUri(uri)) {
throw new Error('The provided URI was not valid')
}
}
exports.verify = verify
exports.serviceproviders = require('./serviceproviders').serviceproviders
exports.serviceprovidersList = require('./serviceproviders').serviceprovidersList
exports.serviceprovidersList = serviceprovidersList