The URL to check, absolute or relative.
Allowed protocols, data-image policy, and ValidatorOptions.
{ valid, error, url }, where url is the resolved absolute form or null.
// URL HTTPS valide
const result = GeoLeaf.Validators.validateUrl("https://example.com/data.json");
// Returns: { valid: true, error: null, url: 'https://example.com/data.json' }
// Protocole non autorisé
const result2 = GeoLeaf.Validators.validateUrl("ftp://example.com/file");
// Returns: { valid: false, error: 'Protocol "ftp:" not allowed', url: null }
// Autoriser seulement HTTPS
const result3 = GeoLeaf.Validators.validateUrl("http://example.com", {
allowedProtocols: ["https:"],
});
// Returns: { valid: false, error: 'Protocol "http:" not allowed', url: null }
Validates a URL and returns it resolved.
The protocol allow-list is the substance of the check: it is what keeps
javascript:out of an attribute built from profile data.data:URLs are refused unlessallowDataImagesis set, and even then only image MIME types pass.On success the third field carries the resolved absolute URL, so a relative input comes back usable; on failure it is
null.