use crate::error::SamlError;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EndpointUrl(String);
impl EndpointUrl {
pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
let value = value.into();
let parsed = url::Url::parse(&value).map_err(|err| SamlError::Invalid(err.to_string()))?;
if matches!(parsed.scheme(), "http" | "https") && parsed.has_host() {
return Ok(Self(value));
}
Err(SamlError::Invalid(
"endpoint URL must be absolute HTTP(S)".into(),
))
}
pub fn as_str(&self) -> &str {
&self.0
}
}