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)
| 439 | /// `https://atomic.storage` → `"atomic-storage"` (no subdomain) |
| 440 | /// `http://localhost:8080` → `"localhost"` |
| 441 | fn derive_profile_name(server_url: &str) -> Option<String> { |
| 442 | let url = url::Url::parse(server_url).ok()?; |
| 443 | let host = url.host_str()?; |
| 444 | |
| 445 | // If the host has a subdomain, use that as the profile name. |
| 446 | if let Some(dot) = host.find('.') { |
| 447 | let label = &host[..dot]; |
| 448 | if !label.is_empty() && label != "www" { |
| 449 | return Some(label.to_string()); |
| 450 | } |
| 451 | // No useful subdomain — fall through to full host slug. |
| 452 | } |
| 453 | |
| 454 | // Slug the host: replace dots and colons with hyphens, strip port. |
| 455 | let host_no_port = host.split(':').next().unwrap_or(host); |
| 456 | let slug = host_no_port.replace('.', "-"); |
| 457 | if slug.is_empty() { |
| 458 | None |
| 459 | } else { |
| 460 | Some(slug) |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | /// Interpret the registration response's tenancy signal. |
| 465 | /// |