Skip to content

Commit 587e962

Browse files
authored
Merge pull request #790 from crowlKats/remove_idna
Make IDNA dependency non-optional
2 parents a3df365 + eaa23e5 commit 587e962

File tree

7 files changed

+2
-24
lines changed

7 files changed

+2
-24
lines changed

url/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ debugger_test_parser = "0.1"
2929

3030
[dependencies]
3131
form_urlencoded = { version = "1.0.0", path = "../form_urlencoded" }
32-
idna = { version = "0.2.0", path = "../idna", optional = true }
32+
idna = { version = "0.2.0", path = "../idna" }
3333
percent-encoding = { version = "2.1.0", path = "../percent_encoding" }
3434
serde = {version = "1.0", optional = true, features = ["derive"]}
3535

3636
[features]
37-
default = ["idna"]
37+
default = []
3838
# UNSTABLE FEATURES (requires Rust nightly)
3939
# Enable to use the #[debugger_visualizer] attribute.
4040
debugger_visualizer = []

url/src/host.rs

-13
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,9 @@ impl Host<String> {
162162
}
163163

164164
/// convert domain with idna
165-
#[cfg(feature = "idna")]
166165
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
167166
idna::domain_to_ascii(domain).map_err(Into::into)
168167
}
169-
170-
/// checks domain is ascii
171-
#[cfg(not(feature = "idna"))]
172-
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
173-
// without idna feature, we can't verify that xn-- domains correctness
174-
let domain = domain.to_lowercase();
175-
if domain.is_ascii() && domain.split('.').all(|s| !s.starts_with("xn--")) {
176-
Ok(domain)
177-
} else {
178-
Err(ParseError::InvalidDomainCharacter)
179-
}
180-
}
181168
}
182169

183170
impl<S: AsRef<str>> fmt::Display for Host<S> {

url/src/origin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ impl Origin {
8686
}
8787

8888
/// <https://html.spec.whatwg.org/multipage/#unicode-serialisation-of-an-origin>
89-
#[cfg(feature = "idna")]
9089
pub fn unicode_serialization(&self) -> String {
9190
match *self {
9291
Origin::Opaque(_) => "null".to_owned(),

url/src/parser.rs

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ simple_enum_error! {
8787
Overflow => "URLs more than 4 GB are not supported",
8888
}
8989

90-
#[cfg(feature = "idna")]
9190
impl From<::idna::Errors> for ParseError {
9291
fn from(_: ::idna::Errors) -> ParseError {
9392
ParseError::IdnaError

url/src/quirks.rs

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pub fn domain_to_ascii(domain: &str) -> String {
6666
}
6767

6868
/// https://url.spec.whatwg.org/#dom-url-domaintounicode
69-
#[cfg(feature = "idna")]
7069
pub fn domain_to_unicode(domain: &str) -> String {
7170
match Host::parse(domain) {
7271
Ok(Host::Domain(ref domain)) => {

url/tests/data.rs

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use url::{quirks, Url};
1515

1616
#[test]
1717
fn urltestdata() {
18-
#[cfg(not(feature = "idna"))]
1918
let idna_skip_inputs = [
2019
"http://www.foo。bar.com",
2120
"http://Go.com",
@@ -46,7 +45,6 @@ fn urltestdata() {
4645
let input = entry.take_string("input");
4746
let failure = entry.take_key("failure").is_some();
4847

49-
#[cfg(not(feature = "idna"))]
5048
{
5149
if idna_skip_inputs.contains(&input.as_str()) {
5250
continue;
@@ -133,7 +131,6 @@ fn setters_tests() {
133131
let mut tests = json.take_key(attr).unwrap();
134132
for mut test in tests.as_array_mut().unwrap().drain(..) {
135133
let comment = test.take_key("comment").map(|s| s.string());
136-
#[cfg(not(feature = "idna"))]
137134
{
138135
if let Some(comment) = comment.as_ref() {
139136
if comment.starts_with("IDNA Nontransitional_Processing") {

url/tests/unit.rs

-3
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ fn host_serialization() {
304304
);
305305
}
306306

307-
#[cfg(feature = "idna")]
308307
#[test]
309308
fn test_idna() {
310309
assert!("http://goșu.ro".parse::<Url>().is_ok());
@@ -540,7 +539,6 @@ fn test_origin_opaque() {
540539
assert!(!&Url::parse("blob:malformed//").unwrap().origin().is_tuple())
541540
}
542541

543-
#[cfg(feature = "idna")]
544542
#[test]
545543
fn test_origin_unicode_serialization() {
546544
let data = [
@@ -713,7 +711,6 @@ fn test_set_href() {
713711
);
714712
}
715713

716-
#[cfg(feature = "idna")]
717714
#[test]
718715
fn test_domain_encoding_quirks() {
719716
use url::quirks::{domain_to_ascii, domain_to_unicode};

0 commit comments

Comments
 (0)