Skip to content

Commit 896662b

Browse files
committed
Merge remote-tracking branch 'origin/master' into 2.0
2 parents 6e08201 + 695351b commit 896662b

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rust-url
22
========
33

4-
[![Travis build Status](https://travis-ci.org/servo/rust-url.svg?branch=master)](https://travis-ci.org/servo/rust-url) [![Appveyor build status](https://ci.appveyor.com/api/projects/status/ulkqx2xcemyod6xa?svg=true)](https://ci.appveyor.com/project/Manishearth/rust-url)
4+
[![Travis build Status](https://travis-ci.com/servo/rust-url.svg?branch=master)](https://travis-ci.com/servo/rust-url) [![Appveyor build status](https://ci.appveyor.com/api/projects/status/ulkqx2xcemyod6xa?svg=true)](https://ci.appveyor.com/project/Manishearth/rust-url)
55

66
URL library for Rust, based on the [URL Standard](https://url.spec.whatwg.org/).
77

src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ impl Url {
909909

910910
/// Return the port number for this URL, if any.
911911
///
912+
/// Note that default port numbers are never reflected by the serialization,
913+
/// use the `port_or_known_default()` method if you want a default port number returned.
914+
///
912915
/// # Examples
913916
///
914917
/// ```
@@ -919,6 +922,9 @@ impl Url {
919922
/// let url = Url::parse("https://example.com")?;
920923
/// assert_eq!(url.port(), None);
921924
///
925+
/// let url = Url::parse("https://example.com:443/")?;
926+
/// assert_eq!(url.port(), None);
927+
///
922928
/// let url = Url::parse("ssh://example.com:22")?;
923929
/// assert_eq!(url.port(), Some(22));
924930
/// # Ok(())
@@ -1383,6 +1389,8 @@ impl Url {
13831389

13841390
/// Change this URL’s port number.
13851391
///
1392+
/// Note that default port numbers are not reflected in the serialization.
1393+
///
13861394
/// If this URL is cannot-be-a-base, does not have a host, or has the `file` scheme;
13871395
/// do nothing and return `Err`.
13881396
///
@@ -1405,6 +1413,22 @@ impl Url {
14051413
/// # run().unwrap();
14061414
/// ```
14071415
///
1416+
/// Known default port numbers are not reflected:
1417+
///
1418+
/// ```rust
1419+
/// use url::Url;
1420+
/// # use std::error::Error;
1421+
///
1422+
/// # fn run() -> Result<(), Box<Error>> {
1423+
/// let mut url = Url::parse("https://example.org/")?;
1424+
///
1425+
/// url.set_port(Some(443)).map_err(|_| "cannot be base")?;
1426+
/// assert!(url.port().is_none());
1427+
/// # Ok(())
1428+
/// # }
1429+
/// # run().unwrap();
1430+
/// ```
1431+
///
14081432
/// Cannot set port for cannot-be-a-base URLs:
14091433
///
14101434
/// ```

0 commit comments

Comments
 (0)