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)
| 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> { |
no test coverage detected