Selaa lähdekoodia

modify per comment, add a note in document for idna feature

lishuo 4 vuotta sitten
vanhempi
sitoutus
fc7dfa597f
2 muutettua tiedostoa jossa 11 lisäystä ja 3 poistoa
  1. 10 0
      url/src/lib.rs
  2. 1 3
      url/src/origin.rs

+ 10 - 0
url/src/lib.rs

@@ -118,6 +118,16 @@ See [serde documentation](https://serde.rs) for more information.
 ```toml
 url = { version = "2", features = ["serde"] }
 ```
+
+# Feature: `idna`
+
+You can opt out [idna](https://en.wikipedia.org/wiki/Internationalized_domain_name) support
+to reduce final binary size.
+
+```tomo
+url = { version = "2", default-features = false }
+```
+
 */
 
 #![doc(html_root_url = "https://docs.rs/url/2.2.2")]

+ 1 - 3
url/src/origin.rs

@@ -9,8 +9,6 @@
 use crate::host::Host;
 use crate::parser::default_port;
 use crate::Url;
-#[cfg(feature = "idna")]
-use idna::domain_to_unicode;
 use std::sync::atomic::{AtomicUsize, Ordering};
 
 pub fn url_origin(url: &Url) -> Origin {
@@ -95,7 +93,7 @@ impl Origin {
                 let host = match *host {
                     Host::Domain(ref domain) => {
                         #[cfg(feature = "idna")]
-                        let (domain, _errors) = domain_to_unicode(domain);
+                        let (domain, _errors) = idna::domain_to_unicode(domain);
                         #[cfg(not(feature = "idna"))]
                         let domain = domain.clone();