@@ -110,26 +110,16 @@ impl SharedAppList {
110110 pub async fn find_app_by_domain ( & self , domain : & str ) -> Option < AppData > {
111111 let apps = self . apps . read ( ) . await ;
112112 for app in apps. values ( ) {
113- // Check settings-based domains
113+ // Check settings-based domains (custom and auto-generated)
114114 if let Some ( settings) = & app. settings {
115115 for service in & settings. public_services {
116- // Check explicit custom domains
117116 if service
118- . domains
117+ . get_domains ( & settings . domain )
119118 . iter ( )
120119 . any ( |d| d. eq_ignore_ascii_case ( domain) )
121120 {
122121 return Some ( app. clone ( ) ) ;
123122 }
124- // Check auto-generated domain: {service_name}.{settings.domain}
125- // Must match the Traefik label format in
126- // scotty/src/docker/loadbalancer/traefik.rs
127- if !settings. domain . is_empty ( ) {
128- let auto_domain = format ! ( "{}.{}" , service. service, settings. domain) ;
129- if auto_domain. eq_ignore_ascii_case ( domain) {
130- return Some ( app. clone ( ) ) ;
131- }
132- }
133123 }
134124 }
135125
@@ -268,7 +258,7 @@ mod tests {
268258 #[ tokio:: test]
269259 async fn test_find_app_by_domain_case_insensitive ( ) {
270260 let list = SharedAppList :: new ( ) ;
271- let app = make_app_with_settings (
261+ let app_custom = make_app_with_settings (
272262 "myapp" ,
273263 "myapp.example.com" ,
274264 vec ! [ ServicePortMapping {
@@ -277,16 +267,26 @@ mod tests {
277267 domains: vec![ "Custom.Example.COM" . to_string( ) ] ,
278268 } ] ,
279269 ) ;
280- list. add_app ( app) . await . unwrap ( ) ;
270+ let app_auto = make_app_with_settings (
271+ "otherapp" ,
272+ "otherapp.example.com" ,
273+ vec ! [ ServicePortMapping {
274+ service: "api" . to_string( ) ,
275+ port: 3000 ,
276+ domains: vec![ ] ,
277+ } ] ,
278+ ) ;
279+ list. add_app ( app_custom) . await . unwrap ( ) ;
280+ list. add_app ( app_auto) . await . unwrap ( ) ;
281281
282- // Lowercase lookup should match uppercase stored domain
282+ // Lowercase lookup should match uppercase stored custom domain
283283 let found = list. find_app_by_domain ( "custom.example.com" ) . await ;
284284 assert ! ( found. is_some( ) ) ;
285285 assert_eq ! ( found. unwrap( ) . name, "myapp" ) ;
286286
287287 // Uppercase lookup should match auto-generated domain
288- let found = list. find_app_by_domain ( "WEB.MYAPP .EXAMPLE.COM" ) . await ;
288+ let found = list. find_app_by_domain ( "API.OTHERAPP .EXAMPLE.COM" ) . await ;
289289 assert ! ( found. is_some( ) ) ;
290- assert_eq ! ( found. unwrap( ) . name, "myapp " ) ;
290+ assert_eq ! ( found. unwrap( ) . name, "otherapp " ) ;
291291 }
292292}
0 commit comments