BasicOIDC/src/data/login_redirect.rs

22 lines
515 B
Rust
Raw Normal View History

2022-04-19 15:49:57 +00:00
#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Clone)]
2022-04-19 17:30:14 +00:00
pub struct LoginRedirect(String);
2022-04-19 15:49:57 +00:00
2022-04-19 17:30:14 +00:00
impl LoginRedirect {
2022-04-19 15:49:57 +00:00
pub fn get(&self) -> &str {
match self.0.starts_with('/') && !self.0.starts_with("//") {
true => self.0.as_str(),
false => "/",
}
}
pub fn get_encoded(&self) -> String {
urlencoding::encode(self.get()).to_string()
}
}
2022-04-19 17:30:14 +00:00
impl Default for LoginRedirect {
2022-04-19 15:49:57 +00:00
fn default() -> Self {
Self("/".to_string())
}
2022-11-11 11:26:02 +00:00
}