|
|
|
@ -7,7 +7,7 @@ const url = require("url");
|
|
|
|
|
const asExpression = require("as-expression");
|
|
|
|
|
const dotty = require("dotty");
|
|
|
|
|
const getJson = require("axios-get-json-response");
|
|
|
|
|
const { ValidationError, validateValue, required, isString, arrayOf, allowExtraProperties } = require("validatem");
|
|
|
|
|
const { ValidationError, validateValue, validateArguments, required, isString, arrayOf, allowExtraProperties } = require("validatem");
|
|
|
|
|
|
|
|
|
|
let LookupFailed = createError("LookupFailed");
|
|
|
|
|
let MethodNotAvailable = createError("MethodNotAvailable");
|
|
|
|
@ -155,11 +155,15 @@ function attemptWellKnown(host) {
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
LookupFailed: LookupFailed,
|
|
|
|
|
discover: function (host) {
|
|
|
|
|
discover: function (hostname) {
|
|
|
|
|
validateArguments(arguments, [
|
|
|
|
|
["hostname", required, isString]
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return Promise.try(() => {
|
|
|
|
|
return attemptWellKnown(host);
|
|
|
|
|
return attemptWellKnown(hostname);
|
|
|
|
|
}).catch(MethodNotAvailable, () => {
|
|
|
|
|
return attemptLiteralHostname(host);
|
|
|
|
|
return attemptLiteralHostname(hostname);
|
|
|
|
|
}).catch(MethodNotAvailable, () => {
|
|
|
|
|
throwLookupError("none of the autodiscovery methods were available");
|
|
|
|
|
});
|
|
|
|
|