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)
| 348 | /// `https://atomic.storage` → `"atomic-storage"` (no subdomain) |
| 349 | /// `http://localhost:8080` → `"localhost"` |
| 350 | fn derive_profile_name(server_url: &str) -> Option<String> { |
| 351 | let url = url::Url::parse(server_url).ok()?; |
| 352 | let host = url.host_str()?; |
| 353 | |
| 354 | // If the host has a subdomain, use that as the profile name. |
| 355 | if let Some(dot) = host.find('.') { |
| 356 | let label = &host[..dot]; |
| 357 | if !label.is_empty() && label != "www" { |
| 358 | return Some(label.to_string()); |
| 359 | } |
| 360 | // No useful subdomain — fall through to full host slug. |
| 361 | } |
| 362 | |
| 363 | // Slug the host: replace dots and colons with hyphens, strip port. |
| 364 | let host_no_port = host.split(':').next().unwrap_or(host); |
| 365 | let slug = host_no_port.replace('.', "-"); |
| 366 | if slug.is_empty() { |
| 367 | None |
| 368 | } else { |
| 369 | Some(slug) |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /// Interpret the registration response's tenancy signal. |
| 374 | /// |