forked from Mirrors/doipjs
Allow opts to pass through to matching function
This commit is contained in:
parent
c781d4a525
commit
2b22799fff
2 changed files with 4 additions and 4 deletions
|
@ -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
|
||||||
|
|
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue