anything-llm/collector/utils/url/index.js

15 lines
271 B
JavaScript
Raw Normal View History

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