Skip to main content

validate_url_sync

Function validate_url_sync 

Source
pub fn validate_url_sync(s: &str, policy: IpPolicy) -> Result<(), Error>
Expand description

Synchronous best-effort URL validation: scheme + literal-IP only.

Use when the constructor is not async (TokenExchangeAuthProvider::new, OpenAiCompatProvider::new, etc). Returns Ok for hostnames (no DNS lookup performed) under IpPolicy::Strict — call SafeUrl::parse on the actual request path for the full check including DNS resolution.

Catches the obvious misconfigurations (e.g., http://127.0.0.1 or http://169.254.169.254) at construction time. Defense in depth, not a substitute for SafeUrl::parse.