Question

According to RFC 3986 Section 3 - Syntax Components:

The scheme and path components are required, though the path may be empty (no characters).

Can someone clarify how the path component can be required if it's able to be empty? Maybe I'm misunderstanding the definition of "required" in this context, but I assumed it to mean something along the lines of "must be non-empty," which obviously conflicts with the spec here.

Was it helpful?

Solution

Here, "required" means merely "always present": the scheme and path components of an absolute URI are always present.

The scheme component can't be empty because the production "scheme" requires at least one character.

The path component can be empty because the production "path-empty" (part of "hier-part") consists of zero characters.

OTHER TIPS

A common practical example of an empty - more precisely, an abempty - path is a URI like http://stackoverflow.com where the path is empty. The authority component (in this case it is stackoverflow.com) alone isn't enough information to identify a resource.

When the authority is empty, the path must begin with a / in order to distinguish the path from the authority - scheme:/// is a valid URI - hence an abempty path. Also take a look at this answer for further reading.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top