karwa / swift-url

A new URL type for Swift

Home Page:https://karwa.github.io/swift-url/main/documentation/weburl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide an API for parsing hostnames

karwa opened this issue · comments

commented

Currently, the API provides an IPv4Address.ParserResult type, which returns either success, failure, or "notAnIPAddress". The latter is supposed to mean that the hostname should not be interpreted as an IPv4 address, and perhaps as a domain or opaque hostname instead. The idea was that this API could be useful for applications which accept a user-provided hostname or read a hostname from a configuration file.

Recent changes to the URL Standard make it impractical to make this distinction at the IPv4 parser level, and it doesn't cover other forms of addresses such as IPv6, so the previous API will be deprecated. Instead, it might be better to provide a more complete host-parsing API. This would also perform IDNA once we support that.

Since the allowed kinds of hosts depend on the URL's scheme, we would probably assume a network (i.e. non-opaque), non-file host, and parse the given hostname in the same way we would parse an HTTP URL.