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)
| 546 | /// `https://alice.atomic.storage/...` → `https://atomic.storage` |
| 547 | /// `http://localhost:8080/...` (no subdomain) → `http://localhost:8080` |
| 548 | fn apex_server_url(remote_url: &str) -> Option<String> { |
| 549 | let url = Url::parse(remote_url).ok()?; |
| 550 | let scheme = url.scheme(); |
| 551 | let host = url.host_str()?; |
| 552 | |
| 553 | // Strip the first label if there is a subdomain; leave a bare host |
| 554 | // (e.g. "localhost") untouched. |
| 555 | let apex_host = match host.find('.') { |
| 556 | Some(dot) => &host[dot + 1..], |
| 557 | None => host, |
| 558 | }; |
| 559 | |
| 560 | match url.port() { |
| 561 | Some(port) => Some(format!("{scheme}://{apex_host}:{port}")), |
| 562 | None => Some(format!("{scheme}://{apex_host}")), |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | /// Extract the identity name from a remote URL alone (no server config). |
| 567 | /// |
no test coverage detected