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

Method org_base_url

atomic-config/src/lib.rs:126–142  ·  view source on GitHub ↗

Build the org-scoped base URL. Given `url = "https://atomic.storage"` and `org = "alice"`, returns `"https://alice.atomic.storage"`. Given `url = "http://localhost:8080"` and `org = "alice"`, returns `"http://alice.localhost:8080"`.

(&self, org_slug: &str)

Source from the content-addressed store, hash-verified

124 /// Given `url = "http://localhost:8080"` and `org = "alice"`,
125 /// returns `"http://alice.localhost:8080"`.
126 pub fn org_base_url(&self, org_slug: &str) -> Option<String> {
127 let url = self.url.as_ref()?;
128
129 // Parse the URL to extract scheme, host, port
130 let url_parsed = url::Url::parse(url).ok()?;
131 let scheme = url_parsed.scheme();
132 let host = url_parsed.host_str()?;
133 let port = url_parsed.port();
134
135 let base = if let Some(port) = port {
136 format!("{}://{}.{}:{}", scheme, org_slug, host, port)
137 } else {
138 format!("{}://{}.{}", scheme, org_slug, host)
139 };
140
141 Some(base)
142 }
143
144 /// Get the org-scoped base URL using the default org.
145 pub fn default_org_base_url(&self) -> Option<String> {

Callers 2

build_client_with_orgFunction · 0.80
default_org_base_urlMethod · 0.80

Calls 1

as_refMethod · 0.80

Tested by

no test coverage detected