Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some questions arose up while I was doing this implementation.
port_int
toUrl
, my initial implementation actually handled it by storing the actual port always inUrl::port
and when using the methodUrl::port()
it would filter based on scheme defaults. In addition theUrl::serialization
would always contain the correctly removed default port. This implementation caused a lot of edge cases to arise, so I avoided it by doing it in a separate field.Url::set_scheme
,Url::port_int
is removed if it was the scheme default, see Changing the scheme can break things #61. Probably it would be more intuitive that ifUrl::port_int
is empty, ergo the user didn't define a port (default or not), then having the new port be the default port for that scheme makes sense. But if the user deliberately defined the default port on the URL, changing the scheme shouldn't change the port.Url
s with differentUrl::port_int
might turn out to be equal, because it comparesUrl::serialization
, and default ports for scheme aren't reflected in the serialization.Personally I'm fine with last two points, I consider them edge-cases that are fine for the url crate to ignore.
Fixes #706.