Quellcode durchsuchen

Update `Url::domain` docs to show that it includes subdomain (#1057)

* Update `Url::domain` docs to show that it includes subdomain

Signed-off-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com>

* Add subdomain example for `Url::host_str`

Signed-off-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com>

---------

Signed-off-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com>
Co-authored-by: Manish Goregaokar <manishsmail@gmail.com>
supercoolspy vor 1 Jahr
Ursprung
Commit
88826bd3c3
1 geänderte Dateien mit 7 neuen und 0 gelöschten Zeilen
  1. 7 0
      url/src/lib.rs

+ 7 - 0
url/src/lib.rs

@@ -1144,6 +1144,9 @@ impl Url {
     /// let url = Url::parse("https://127.0.0.1/index.html")?;
     /// assert_eq!(url.host_str(), Some("127.0.0.1"));
     ///
+    /// let url = Url::parse("https://subdomain.example.com")?;
+    /// assert_eq!(url.host_str(), Some("subdomain.example.com"));
+    ///
     /// let url = Url::parse("ftp://rms@example.com")?;
     /// assert_eq!(url.host_str(), Some("example.com"));
     ///
@@ -1223,6 +1226,10 @@ impl Url {
     ///
     /// let url = Url::parse("https://example.com/")?;
     /// assert_eq!(url.domain(), Some("example.com"));
+    ///
+    /// let url = Url::parse("https://subdomain.example.com/")?;
+    /// assert_eq!(url.domain(), Some("subdomain.example.com"));
+    ///
     /// # Ok(())
     /// # }
     /// # run().unwrap();