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)
| 635 | /// `https://alice.atomic.storage/...` → `https://atomic.storage` |
| 636 | /// `http://localhost:8080/...` (no subdomain) → `http://localhost:8080` |
| 637 | fn apex_server_url(remote_url: &str) -> Option<String> { |
| 638 | let url = Url::parse(remote_url).ok()?; |
| 639 | let scheme = url.scheme(); |
| 640 | let host = url.host_str()?; |
| 641 | |
| 642 | // Strip the first label if there is a subdomain; leave a bare host |
| 643 | // (e.g. "localhost") untouched. |
| 644 | let apex_host = match host.find('.') { |
| 645 | Some(dot) => &host[dot + 1..], |
| 646 | None => host, |
| 647 | }; |
| 648 | |
| 649 | match url.port() { |
| 650 | Some(port) => Some(format!("{scheme}://{apex_host}:{port}")), |
| 651 | None => Some(format!("{scheme}://{apex_host}")), |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | /// Extract the first subdomain label from a host string. |
| 656 | /// |
no test coverage detected