Skip to main content

check

Function check 

Source
pub fn check(url: &ProxyUrl) -> Vec<QuirkMatch>
Expand description

Returns every VendorQuirk that matches url.

The function walks the const VENDOR_QUIRKS slice using pure pointer/length compares (no I/O, no locks, no per-call allocations beyond the returned Vec). In the common case where the URL host is not in the built-in table, the function short- circuits on the first non-matching host_suffix and returns Vec::new() without further allocation beyond the empty Vec itself.

Quirk triggers:

Host matching is subdomain-aware: proxy.crawlera.com matches the "crawlera.com" suffix, but "mycrawlera.com" does not (no subdomain boundary).

ยงExample

use stygian_proxy::vendor_quirks::{check, ProxyUrl, QuirkSeverity, Scheme};

// Crawlera 8011 + https โ†’ 1 Error match (scheme mismatch).
let url = ProxyUrl::parse("https://user:pass@proxy.crawlera.com:8011").unwrap();
let m = check(&url);
assert_eq!(m.len(), 1);
assert_eq!(m[0].severity, QuirkSeverity::Error);
assert_eq!(m[0].required_scheme, Scheme::Http);

// Crawlera 8011 + http โ†’ 0 matches (compliant URL).
let url = ProxyUrl::parse("http://user:pass@proxy.crawlera.com:8011").unwrap();
assert!(check(&url).is_empty());

// Bright Data super-proxy โ†’ 1 Warning regardless of username.
let url = ProxyUrl::parse("http://user@brd.superproxy.io:22225").unwrap();
assert_eq!(check(&url).len(), 1);
assert_eq!(check(&url)[0].severity, QuirkSeverity::Warning);