Compare commits

...

3 Commits

@ -58,6 +58,10 @@ This error type correctly inherits from `Error`, and can be used with `instanceo
## Changelog ## Changelog
### 1.0.1 (August 30, 2019)
- Added input validation with an informative error to the `discover` method.
### 1.0.0 (August 30, 2019) ### 1.0.0 (August 30, 2019)
Initial release. Initial release.

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

@ -1,7 +1,7 @@
{ {
"name": "@modular-matrix/autodiscover-client-configuration", "name": "@modular-matrix/autodiscover-client-configuration",
"description": "Auto-discovers Matrix client configuration for a given hostname (including eg. doing a .well-known lookup)", "description": "Auto-discovers Matrix client configuration for a given hostname (including eg. doing a .well-known lookup)",
"version": "1.0.0", "version": "1.0.1",
"main": "index.js", "main": "index.js",
"repository": "http://git.cryto.net/modular-matrix/autodiscover-client-configuration.git", "repository": "http://git.cryto.net/modular-matrix/autodiscover-client-configuration.git",
"author": "Sven Slootweg <admin@cryto.net>", "author": "Sven Slootweg <admin@cryto.net>",

Loading…
Cancel
Save