MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / apex_server_url

Function apex_server_url

atomic-cli/src/commands/auth.rs:501–517  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

499/// `https://alice.atomic.storage/...` → `https://atomic.storage`
500/// `http://localhost:8080/...` (no subdomain) → `http://localhost:8080`
501fn apex_server_url(remote_url: &str) -> Option<String> {
502 let url = Url::parse(remote_url).ok()?;
503 let scheme = url.scheme();
504 let host = url.host_str()?;
505
506 // Strip the first label if there is a subdomain; leave a bare host
507 // (e.g. "localhost") untouched.
508 let apex_host = match host.find('.') {
509 Some(dot) => &host[dot + 1..],
510 None => host,
511 };
512
513 match url.port() {
514 Some(port) => Some(format!("{scheme}://{apex_host}:{port}")),
515 None => Some(format!("{scheme}://{apex_host}")),
516 }
517}
518
519/// Extract the identity name from a remote URL alone (no server config).
520///

Callers 1

attach_identityFunction · 0.85

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected