Derive a short profile name from a server URL. `https://staging.atomic.storage` → `"staging"` `https://atomic.storage` → `"atomic-storage"` (no subdomain) `http://localhost:8080` → `"localhost"`
(server_url: &str)
| 419 | /// `https://atomic.storage` → `"atomic-storage"` (no subdomain) |
| 420 | /// `http://localhost:8080` → `"localhost"` |
| 421 | fn derive_profile_name(server_url: &str) -> Option<String> { |
| 422 | let url = url::Url::parse(server_url).ok()?; |
| 423 | let host = url.host_str()?; |
| 424 | |
| 425 | // If the host has a subdomain, use that as the profile name. |
| 426 | if let Some(dot) = host.find('.') { |
| 427 | let label = &host[..dot]; |
| 428 | if !label.is_empty() && label != "www" { |
| 429 | return Some(label.to_string()); |
| 430 | } |
| 431 | // No useful subdomain — fall through to full host slug. |
| 432 | } |
| 433 | |
| 434 | // Slug the host: replace dots and colons with hyphens, strip port. |
| 435 | let host_no_port = host.split(':').next().unwrap_or(host); |
| 436 | let slug = host_no_port.replace('.', "-"); |
| 437 | if slug.is_empty() { |
| 438 | None |
| 439 | } else { |
| 440 | Some(slug) |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /// Interpret the registration response's tenancy signal. |
| 445 | /// |