forked from Mirrors/doipjs
Improve handling of opts
This commit is contained in:
parent
24af3053b4
commit
8c14d2533c
2 changed files with 7 additions and 2 deletions
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
const mergeOptions = require('merge-options')
|
||||||
const validUrl = require('valid-url')
|
const validUrl = require('valid-url')
|
||||||
const serviceproviders = require('./serviceproviders')
|
const serviceproviders = require('./serviceproviders')
|
||||||
const claimVerification = require('./claimVerification')
|
const claimVerification = require('./claimVerification')
|
||||||
|
@ -22,9 +23,12 @@ const verify = async (uri, fingerprint, opts) => {
|
||||||
if (!fingerprint) { fingerprint = null }
|
if (!fingerprint) { fingerprint = null }
|
||||||
if (!opts) { opts = {} }
|
if (!opts) { opts = {} }
|
||||||
|
|
||||||
if (!('doipProxyHostname' in opts) || !opts.doipProxyHostname) {
|
const defaultOpts = {
|
||||||
opts.doipProxyHostname = 'proxy.keyoxide.org'
|
returnMatchesOnly: false,
|
||||||
|
proxyPolicy: 'adaptive',
|
||||||
|
doipProxyHostname: 'proxy.keyoxide.org'
|
||||||
}
|
}
|
||||||
|
opts = mergeOptions(defaultOpts, opts)
|
||||||
|
|
||||||
if (!validUrl.isUri(uri)) {
|
if (!validUrl.isUri(uri)) {
|
||||||
throw new Error('Not a valid URI')
|
throw new Error('Not a valid URI')
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const generateProxyURL = (type, url, opts) => {
|
const generateProxyURL = (type, url, opts) => {
|
||||||
|
if (!opts || !opts.doipProxyHostname) { return null }
|
||||||
return `https://${opts.doipProxyHostname}/api/1/get/${type}/${encodeURIComponent(url)}`
|
return `https://${opts.doipProxyHostname}/api/1/get/${type}/${encodeURIComponent(url)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue