Skip to main content

is_allowed_domain

Function is_allowed_domain 

Source
pub fn is_allowed_domain(url: &str, allowed: &[&str]) -> bool
Expand description

Return true if url uses HTTPS and its host exactly matches one of the allowed domains.

This is a convenience helper for service-crate constructors that want to enforce a fixed set of known-good endpoints. Matching is against the bare hostname only — port and path are excluded from the comparison.

§Example

use hooksmith_core::is_allowed_domain;

assert!(is_allowed_domain("https://hooks.slack.com/services/T/B/X", &["hooks.slack.com"]));
assert!(!is_allowed_domain("https://evil.com/hooks.slack.com", &["hooks.slack.com"]));
assert!(!is_allowed_domain("http://hooks.slack.com/services/T/B/X", &["hooks.slack.com"]));