From 4ad1201032457aad308a1cff897ba1cb072ec176 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 3 Dec 2023 13:39:23 +0100 Subject: [PATCH] Rename from_root_domain to from_root_url --- src/instance.rs | 6 +++--- src/lib.rs | 4 ++-- tests/urlbundle.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/instance.rs b/src/instance.rs index 6a3b9af..90ee1fa 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -107,12 +107,12 @@ impl Instance { None } - /// Creates a new [`Instance`] by trying to get the [relevant instance urls](UrlBundle) from a root domain. + /// Creates a new [`Instance`] by trying to get the [relevant instance urls](UrlBundle) from a root url. /// Shorthand for `Instance::new(UrlBundle::from_root_domain(root_domain).await?)`. /// /// If `limited` is `true`, then Chorus will track and enforce rate limits for this instance. - pub async fn from_root_domain(root_domain: &str, limited: bool) -> ChorusResult { - let urls = UrlBundle::from_root_domain(root_domain).await?; + pub async fn from_root_url(root_url: &str, limited: bool) -> ChorusResult { + let urls = UrlBundle::from_root_url(root_url).await?; Instance::new(urls, limited).await } } diff --git a/src/lib.rs b/src/lib.rs index 47fda75..80374fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,7 +189,7 @@ impl UrlBundle { url_string } - /// Performs a few HTTP requests to try and retrieve a `UrlBundle` from an instances' root domain. + /// Performs a few HTTP requests to try and retrieve a `UrlBundle` from an instances' root url. /// The method tries to retrieve the `UrlBundle` via these three strategies, in order: /// - GET: `$url/.well-known/spacebar` -> Retrieve UrlBundle via `$wellknownurl/api/policies/instance/domains` /// - GET: `$url/api/policies/instance/domains` @@ -199,7 +199,7 @@ impl UrlBundle { /// stores the CDN and WSS URLs under the `$api/policies/instance/domains` endpoint. If all three /// of the above approaches fail, it is very likely that the instance is misconfigured, unreachable, or that /// a wrong URL was provided. - pub async fn from_root_domain(url: &str) -> ChorusResult { + pub async fn from_root_url(url: &str) -> ChorusResult { let parsed = UrlBundle::parse_url(url.to_string()); let client = reqwest::Client::new(); let request_wellknown = client diff --git a/tests/urlbundle.rs b/tests/urlbundle.rs index 94dcc6d..790229b 100644 --- a/tests/urlbundle.rs +++ b/tests/urlbundle.rs @@ -11,9 +11,9 @@ wasm_bindgen_test_configure!(run_in_browser); async fn test_parse_url() { // TODO: Currently only tests two of the three branches in UrlBundle::from_root_domain. let url = url::Url::parse("http://localhost:3001/").unwrap(); - UrlBundle::from_root_domain(url.as_str()).await.unwrap(); + UrlBundle::from_root_url(url.as_str()).await.unwrap(); let url = url::Url::parse("http://localhost:3001/api/").unwrap(); - UrlBundle::from_root_domain(url.as_str()).await.unwrap(); + UrlBundle::from_root_url(url.as_str()).await.unwrap(); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]