Allow opts to pass through to matching function

This commit is contained in:
Yarmo Mackenbach 2020-10-25 01:02:08 +02:00
parent c781d4a525
commit 2b22799fff
2 changed files with 4 additions and 4 deletions

View file

@ -21,14 +21,14 @@ const claimVerification = require('./claimVerification')
const utils = require('./utils') const utils = require('./utils')
const verify = async (uri, fingerprint, opts) => { const verify = async (uri, fingerprint, opts) => {
if (!opts) { opts = {} }
if (!fingerprint) { fingerprint = null } if (!fingerprint) { fingerprint = null }
if (!opts) { opts = {} }
if (!validUrl.isUri(uri)) { if (!validUrl.isUri(uri)) {
throw new Error('Not a valid URI') throw new Error('Not a valid URI')
} }
const spMatches = serviceproviders.match(uri, fingerprint) const spMatches = serviceproviders.match(uri, opts)
if ('returnMatchesOnly' in opts && opts.returnMatchesOnly) { if ('returnMatchesOnly' in opts && opts.returnMatchesOnly) {
return spMatches return spMatches

View file

@ -27,13 +27,13 @@ const data = {
hackernews: require('./serviceproviders/hackernews'), hackernews: require('./serviceproviders/hackernews'),
} }
const match = (uri) => { const match = (uri, opts) => {
let matches = [], sp let matches = [], sp
list.forEach((spName, i) => { list.forEach((spName, i) => {
sp = data[spName] sp = data[spName]
if (sp.reURI.test(uri)) { if (sp.reURI.test(uri)) {
matches.push(sp.processURI(uri)) matches.push(sp.processURI(uri, opts))
} }
}) })