anything-llm/collector/utils/url/index.js
2024-01-11 12:29:00 -08:00

15 lines
271 B
JavaScript

const VALID_PROTOCOLS = ["https:", "http:"];
function validURL(url) {
try {
const destination = new URL(url);
if (!VALID_PROTOCOLS.includes(destination.protocol)) return false;
return true;
} catch {}
return false;
}
module.exports = {
validURL,
};