Rust-url 0.5.3 supports international domain names

I just published a new version of rust-url that includes @valentin’s work to add support for IDNA.

assert_eq!(Url::parse("http://☃.net/").unwrap().domain(), Some("xn--n3h.net"));

With cargo update -p url to pick it up, you can use this with other libraries that use rust-url. For example (shameless self-advertisement) with Kuchiki (through Hyper):

extern crate kuchiki;  // {version = "0.1.2", features = ["with-hyper"]}

fn main() {
    let document = kuchiki::Html::from_http("http://☃.net/").unwrap().parse();
    let div = document.select("#snowman").unwrap().nth(0).unwrap();
    println!("{}", div.as_node().text_contents().trim());
}
2 Likes