And FWIW, I'm not an expert, but was curious. Wikipedia certainly seems to think that "host" is a universal component of the URI syntax (in particular, it is a sub-component of the "authority" part): https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax It also says "A component is empty if it has no characters", which to me supports the behaviour of using an empty string, if there is no host in the URI to be parsed.
Of course, Wikipedia is no formal spec. But I assume the description is distilled from the respective RFCs and certainly intends to describe common understanding. On Fri, 21 Feb 2025 at 07:50, Axel Wagner <axel.wagner...@googlemail.com> wrote: > I disagree with this logic. I also use "net/url" to parse file:// scheme > URLs, which also don't have a valid interpretation of a "host". > > On Fri, 21 Feb 2025 at 07:18, robert engels <reng...@ix.netcom.com> wrote: > >> I think I disagree. The bnf you are quoting form is from “For example, >> some URI schemes do not allow an <authority> component, and others do not >> use a <query> component.” >> >> The http scheme requires the //. >> >> And since the return struct from URL.parse() has fields like “host”, it >> implies it has semantic understanding, otherwise the only result possible >> >> scheme, andtherest… >> >> with no parsing of other. >> >> The previous email I sent had a reference to the common format of many >> “scheme”s using the authority… but this is not required. >> >> >> > On Feb 21, 2025, at 12:04 AM, 'Dan Kortschak' via golang-nuts < >> golang-nuts@googlegroups.com> wrote: >> > >> > On Thu, 2025-02-20 at 23:38 -0600, robert engels wrote: >> >> Also, see https://datatracker.ietf.org/doc/html/rfc2396#section-3 for >> >> more details on the scheme + authority. >> > >> > >> > The BNF is (including only the parts that are necessary to show >> > validity): >> > >> > absoluteURI = scheme ":" ( hier_part | opaque_part ) >> > hier_part = ( net_path | abs_path ) [ "?" query ] >> > abs_path = "/" path_segments >> > path_segments = segment *( "/" segment ) >> > segment = *pchar *( ";" param ) >> > param = *pchar >> > pchar = unreserved | escaped | >> > ":" | "@" | "&" | "=" | "+" | "$" | "," >> > >> > The original URI (I miswrote URL for URI in my last post — the >> > url.Parse documentation notes "technically, a URI reference") was >> > "http:/127.0.0.1/index.html" which can be broken into: >> > >> > scheme = http >> > abs_path = /127.0.0.1/index.html >> > >> > The url.Parse function doesn't examine semantics, that's the caller's >> > responsibility. The semantics here are clearly wrong, but it's up to >> > the caller to check and ensure that the passed value satisfies the >> > expectations. >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to golang-nuts+unsubscr...@googlegroups.com. >> > To view this discussion visit >> https://groups.google.com/d/msgid/golang-nuts/e5d3b0bf3f9c51c18b4170fc2b15bfae469cf57f.camel%40kortschak.io >> . >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion visit >> https://groups.google.com/d/msgid/golang-nuts/96AA5F8C-CA16-4322-88C4-0B28399203DC%40ix.netcom.com >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfHjUYTRZAk%3DpH2-wrTkrjXWToqcS-yRR%2BTidRnT31G3Mg%40mail.gmail.com.