fix: isUri helper so that it passes ci tests

This commit is contained in:
Julian Lam
2024-01-05 11:38:26 -05:00
parent fcca9259b4
commit 27e256d26e

View File

@@ -14,13 +14,24 @@ const webfingerCache = ttl({ ttl: 1000 * 60 * 60 * 24 }); // 24 hours
const Helpers = module.exports; const Helpers = module.exports;
Helpers.isUri = value => validator.isURL(value, { Helpers.isUri = (value) => {
if (typeof value !== 'string') {
value = String(value);
}
const protocols = ['https'];
if (process.env.CI === 'true') {
protocols.push('http');
}
return validator.isURL(value, {
require_protocol: true, require_protocol: true,
require_host: true, require_host: true,
protocols: ['https'], protocols,
require_valid_protocol: true, require_valid_protocol: true,
require_tld: false, // temporary — for localhost require_tld: false, // temporary — for localhost
}); });
};
Helpers.query = async (id) => { Helpers.query = async (id) => {
const [username, hostname] = id.split('@'); const [username, hostname] = id.split('@');