http icon indicating copy to clipboard operation
http copied to clipboard

Convenience methods to create URL authority from its parts

Open roblabla opened this issue 3 years ago • 0 comments

Currently, the only way to build an Authority object is to parse a string in the form <host>:<port>. This can be a bit inconvenient: In the case the host is an ipv6 address, it needs to be enclosed in [], and the developer will have to do a somewhat complex dance to go from a Host/Port pair to a proper authority string.

It'd be nice to have additional convenience methods, e.g.

// From a host and a port
impl TryFrom<(&str, u16)> for Authority {}

This way, if &str is an IPv6 address (which can be detected by trying to parse it with Ipv6Addr::parse), it can automatically be bracketed.

roblabla avatar Dec 29 '20 10:12 roblabla