Justin
Justin

Reputation: 45350

What is protocol and host combined called?

According to spec and semantics is protocol and host combined: https://example.com still called a host, or is this called a URL, URI, or something else?

Also, is (https) called protocol or scheme? NGINX uses scheme, but I don't see any reference to that origin.

Upvotes: 54

Views: 15033

Answers (5)

Jonathan002
Jonathan002

Reputation: 10278

If you are ok with including the port part in the terminology, javascript parses that part of the url and puts it in the origin property.

const { origin } = new URL(`https://stackoverflow.com:4200/questions/37232382/what-is-protocol-and-host-combined-called`);
console.log(origin) // Outputs: 'https://stackoverflow.com:4200'

Although it seems to omit the port too if it is something familiar like 443

const { origin } = new URL(`https://stackoverflow.com:443/questions/37232382/what-is-protocol-and-host-combined-called`);
console.log(origin) // Outputs: 'https://stackoverflow.com'

Upvotes: 1

sideshowbarker
sideshowbarker

Reputation: 88046

I think the term you may really be looking for is origin, as in RFC 6454.

An origin isn’t just scheme+host, but scheme+host+port, and URLs like https://example.com aren’t actually just scheme+host — because they express a (default) port too: 443, the default TLS port — just as in http://example.com there’s a built-in expression that the port is 80.

I’m not sure what the context was for the original question here, but I know a common case that would normally motivate somebody to want to know what a combination of scheme+host is called is the case where you want to compare two URLs that either have the same host but different schemes, like https://example.com and http://example.com, or that have the same scheme and host but different ports, like http://example.com and http://example.com:8888. And consideration of comparing URLs that way will eventually take you to thinking of them in terms of the "same origin" policy that the entire Web security model is based on.

Upvotes: 68

Geert Van Wonterghem
Geert Van Wonterghem

Reputation: 243

IMHO, origin is not the correct term, since origin refers to "where the communication comes from". But it can also be a destination. Therefore, I think Base URL is the best-fitting term for protocol+host+port. See e.g. https://www.techopedia.com/definition/4858/base-url .

Upvotes: 21

unor
unor

Reputation: 96577

(The following is according to the URI standard STD 66, which currently maps to RFC 3986.)

An absolute URI with an authority (e.g., a domain name, or an IP address) must consist of (in that order)

  1. the scheme component,
  2. :,
  3. //,
  4. the authority component, and
  5. the path component (→ path-abempty).

So according to these rules, https://example.com is

  • either a valid URI (with an empty path),
  • or not yet a valid URI (because it misses the path, which could either be empty or start with /).

(But unless you find this URI in a specific context, one would of course assume that it’s a URI with an empty path.)

However, the HTTP specification RFC 2616 defines scheme-specific rules for HTTP URIs: if the URI is used as Request-URI (see definition), and the URI’s abs_path is empty, it must be given as / (i.e., https://example.com/).

Neither the URI standard nor the HTTP standard define a term that would only describe the combination of the scheme and the authority components.

Upvotes: 6

Michał Bień
Michał Bień

Reputation: 67

Actually, it's all on wiki... https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Relationship_between_URIs.2C_URLs.2C_and_URNs

The name you are looking for is URL. URI is a global name for resource identifiers, and URL is a specific type of URI used in web. And, according to the papers, you should use scheme, not host: https://www.w3.org/TR/uri-clarification/#uri-schemes

Upvotes: -6

Related Questions