@@ -684,6 +684,7 @@ impl Url {
684
684
/// Non-ASCII domains are punycode-encoded per IDNA if this is the host
685
685
/// of a special URL, or percent encoded for non-special URLs.
686
686
/// IPv6 addresses are given between `[` and `]` brackets.
687
+ /// Ports are omitted if they match the well known port of a special URL.
687
688
///
688
689
/// Username and password are percent-encoded.
689
690
///
@@ -702,10 +703,20 @@ impl Url {
702
703
/// assert_eq!(url.authority(), "");
703
704
/// let url = Url::parse("http://example.com/tmp/foo")?;
704
705
/// assert_eq!(url.authority(), "example.com");
706
+ /// let url = Url::parse("ftp://127.0.0.1:21/")?;
707
+ /// assert_eq!(url.authority(), "127.0.0.1");
708
+ /// let url = Url::parse("ftp://[email protected] :2121/")?;
709
+ /// assert_eq!(url.authority(), "[email protected] :2121");
705
710
/// let url = Url::parse("https://:@example.com/")?;
706
711
/// assert_eq!(url.authority(), "example.com");
707
- /// let url = Url::parse("https://user:[email protected] :8080/tmp/foo")?;
708
- /// assert_eq!(url.authority(), "user:[email protected] :8080");
712
+ /// let url = Url::parse("https://:password@[::1]:8080/")?;
713
+ /// assert_eq!(url.authority(), ":password@[::1]:8080");
714
+ /// let url = Url::parse("gopher://user:@àlex.example.com:70")?;
715
+ /// assert_eq!(url.authority(), "user@%C3%A0lex.example.com:70");
716
+ /// let url = Url::parse("irc://àlex:àlex@àlex.рф.example.com:6667/foo")?;
717
+ /// assert_eq!(url.authority(), "%C3%A0lex:%C3%A0lex@%C3%A0lex.%D1%80%D1%84.example.com:6667");
718
+ /// let url = Url::parse("https://àlex:àlex@àlex.рф.example.com:443/foo")?;
719
+ /// assert_eq!(url.authority(), "%C3%A0lex:%C3%[email protected] ");
709
720
/// # Ok(())
710
721
/// # }
711
722
/// # run().unwrap();
0 commit comments