Derive the apex server URL (scheme + host without the leading subdomain label + port) from a tenant-scoped remote URL. `http://alice.localhost:8080/workspaces/w/projects/p/code` → `http://localhost:8080` `https://alice.atomic.storage/...` → `https://atomic.storage` `http://localhost:8080/...` (no subdomain) → `http://localhost:8080`
(remote_url: &str)
| 372 | /// `https://alice.atomic.storage/...` → `https://atomic.storage` |
| 373 | /// `http://localhost:8080/...` (no subdomain) → `http://localhost:8080` |
| 374 | fn apex_server_url(remote_url: &str) -> Option<String> { |
| 375 | let url = Url::parse(remote_url).ok()?; |
| 376 | let scheme = url.scheme(); |
| 377 | let host = url.host_str()?; |
| 378 | |
| 379 | // Strip the first label if there is a subdomain; leave a bare host |
| 380 | // (e.g. "localhost") untouched. |
| 381 | let apex_host = match host.find('.') { |
| 382 | Some(dot) => &host[dot + 1..], |
| 383 | None => host, |
| 384 | }; |
| 385 | |
| 386 | match url.port() { |
| 387 | Some(port) => Some(format!("{scheme}://{apex_host}:{port}")), |
| 388 | None => Some(format!("{scheme}://{apex_host}")), |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /// Extract the identity name from a remote URL alone (no server config). |
| 393 | /// |