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

Function match_server_identity

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

Pick the identity bound to the configured server whose host is the longest dot-boundary suffix of `remote_host`. Longest-suffix wins so a more specific server (`staging.atomic.storage`) beats a broader one (`atomic.storage`) for hosts under both — e.g. `x.staging.atomic.storage` resolves to the staging identity, not prod.

(remote_host: &str, servers: &[(String, String)])

Source from the content-addressed store, hash-verified

116/// beats a broader one (`atomic.storage`) for hosts under both — e.g.
117/// `x.staging.atomic.storage` resolves to the staging identity, not prod.
118fn match_server_identity(remote_host: &str, servers: &[(String, String)]) -> Option<String> {
119 servers
120 .iter()
121 .filter(|(server_host, _)| host_is_under(remote_host, server_host))
122 .max_by_key(|(server_host, _)| server_host.len())
123 .map(|(_, identity)| identity.clone())
124}
125
126/// Whether `remote_host` is the server host itself or a subdomain of it,
127/// matching only on dot boundaries (so `notatomic.storage` does NOT match

Callers 1

Calls 4

host_is_underFunction · 0.85
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected