Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/canonicalize_and_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ pub fn canonicalize_port(
if let Some("") = protocol {
protocol = None;
}
let port = value
.parse::<u16>()
.map_err(|_| Error::Url(url::ParseError::InvalidPort))?;
// Note: this unwrap is safe, because the protocol was previously parsed to be
// valid.
let mut url =
url::Url::parse(&format!("{}://dummy.test", protocol.unwrap_or("dummy")))
.unwrap();
url.set_port(Some(port)).unwrap(); // TODO: dont unwrap, instead ParseError
url::quirks::set_port(&mut url, value)
.map_err(|_| Error::Url(url::ParseError::InvalidPort))?;
Ok(url::quirks::port(&url).to_string())
}

Expand Down
Loading