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

Function extract_subdomain

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

Extract the first subdomain label from a host string. `"alice.localhost"` → `Some("alice")` `"alice.atomic.storage"` → `Some("alice")` `"localhost"` → `None`

(host: &str)

Source from the content-addressed store, hash-verified

252/// `"alice.atomic.storage"` → `Some("alice")`
253/// `"localhost"` → `None`
254fn extract_subdomain(host: &str) -> Option<String> {
255 // Strip port if somehow present (Url should have parsed it out, but be safe).
256 let host = host.split(':').next().unwrap_or(host);
257
258 let dot_pos = host.find('.')?;
259 let subdomain = &host[..dot_pos];
260
261 if subdomain.is_empty() {
262 return None;
263 }
264
265 Some(subdomain.to_string())
266}
267
268#[cfg(test)]
269mod tests {

Callers 1

resolve_identity_nameFunction · 0.85

Calls 2

nextMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected