Przeglądaj źródła

Add Url::serialize_host()

Simon Sapin 12 lat temu
rodzic
commit
fda647f1b8
1 zmienionych plików z 8 dodań i 0 usunięć
  1. 8 0
      src/url.rs

+ 8 - 0
src/url.rs

@@ -286,6 +286,14 @@ impl Url {
         }
         }
     }
     }
 
 
+    #[inline]
+    pub fn serialize_host(&self) -> Option<String> {
+        match self.scheme_data {
+            RelativeSchemeData(ref scheme_data) => Some(scheme_data.host.serialize()),
+            OtherSchemeData(..) => None,
+        }
+    }
+
     #[inline]
     #[inline]
     pub fn serialize_path(&self) -> Option<String> {
     pub fn serialize_path(&self) -> Option<String> {
         match self.scheme_data {
         match self.scheme_data {