From 25dcdc561697bcfbbd21429787a15e6e6449d4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Augusto=20C=C3=A9sar?= Date: Thu, 5 Mar 2026 11:00:51 +0100 Subject: [PATCH] chore: remove unused domain selection order --- linkup/src/session.rs | 69 +------------------------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/linkup/src/session.rs b/linkup/src/session.rs index 68122278..5e3fe603 100644 --- a/linkup/src/session.rs +++ b/linkup/src/session.rs @@ -1,7 +1,4 @@ -use std::{ - cmp::Ordering, - collections::{HashMap, HashSet}, -}; +use std::collections::{HashMap, HashSet}; use thiserror::Error; use regex::Regex; @@ -15,7 +12,6 @@ pub struct Session { pub session_token: String, pub services: HashMap, pub domains: HashMap, - pub domain_selection_order: Vec, pub cache_routes: Option>, } @@ -219,8 +215,6 @@ impl TryFrom for Session { domains.insert(stored_domain.domain, domain); } - let domain_names = domains.keys().cloned().collect(); - let cache_routes = match value.cache_routes { Some(cr) => Some( cr.into_iter() @@ -235,7 +229,6 @@ impl TryFrom for Session { session_token: value.session_token, services, domains, - domain_selection_order: choose_domain_ordering(domain_names), cache_routes, }) } @@ -423,30 +416,6 @@ fn validate_url_origin(url: &Url) -> Result<(), ConfigError> { Ok(()) } -fn choose_domain_ordering(domains: Vec) -> Vec { - let mut sorted_domains = domains; - sorted_domains.sort_by(|a, b| { - let a_subdomains: Vec<&str> = a.split('.').collect(); - let b_subdomains: Vec<&str> = b.split('.').collect(); - - let a_len = a_subdomains.len(); - let b_len = b_subdomains.len(); - - if a_len != b_len { - b_len.cmp(&a_len) - } else { - a_subdomains - .iter() - .zip(b_subdomains.iter()) - .map(|(a_sub, b_sub)| b_sub.len().cmp(&a_sub.len())) - .find(|&ord| ord != Ordering::Equal) - .unwrap_or(Ordering::Equal) - } - }); - - sorted_domains -} - pub fn session_to_json(session: Session) -> String { let storable_session: StorableSession = session.into(); @@ -587,40 +556,4 @@ mod tests { "/static/.*" ); } - - #[test] - fn test_choose_domain_ordering() { - let input = vec![ - "example.com".to_string(), - "api.example.com".to_string(), - "render-api.example.com".to_string(), - "another-example.com".to_string(), - ]; - - let expected_output = vec![ - "render-api.example.com".to_string(), - "api.example.com".to_string(), - "another-example.com".to_string(), - "example.com".to_string(), - ]; - - assert_eq!(choose_domain_ordering(input), expected_output); - } - - #[test] - fn test_choose_domain_ordering_with_same_length() { - let input = vec![ - "a.domain.com".to_string(), - "b.domain.com".to_string(), - "c.domain.com".to_string(), - ]; - - let expected_output = vec![ - "a.domain.com".to_string(), - "b.domain.com".to_string(), - "c.domain.com".to_string(), - ]; - - assert_eq!(choose_domain_ordering(input), expected_output); - } }