30

I have searched for this question, but I haven't found a good answer.

Even the Wikipedia Article on URIs does not explain it thoroughly. I thought it was the protocol for accessing a web page. e.g. HTTP/HTTPS/FTP, but the wiki article says otherwise.

Some URI schemes are not associated with any specific protocol (e.g. "file") and many others do not use the name of a protocol as their prefix (e.g. "news").

I know what part of the URL is the scheme. But my real question was what does it do?

b0yfriend
  • 669
  • 2
  • 6
  • 9
  • Yeah, I just looked at the wikipedia articles (circa 2023), and it is still pretty sparse. I wish they would clear that up, because that part of the URL/URI namespace is used incorrectly, even in modern mobileOS architecture and by the GIT vendors. – benc May 29 '23 at 22:54

6 Answers6

26

Okay, I know what part of the URL is the scheme. But my real question was what does it do?

It simply tells you how to interpret the part of the URL after the colon.

For example, in file://usr/share/doc, the file tells me the part after the colon should be interpreted as a locally-available filesystem path. This isn't identical to a protocol, because there is no transport layer or encoding - a client just uses regular local system calls to access it.

Conversely, https://programmers.stackexchange.com specifies a scheme (https, which in turn means "HTTP over TLS"), but still requires the client to make its own choices about the physical transport used to reach it.

Useless
  • 12,380
  • 2
  • 34
  • 46
  • So `urn:isbn:096139210x` uses double scheme? This comes from the java docs: https://docs.oracle.com/javase/8/docs/api/java/net/URI.html . – NingW Jun 08 '19 at 08:41
  • ````https```` is not a protocol, it's a scheme that tell the client to use the ````TLS```` protocol and port ````443```` That's why schemes are not always associated with a protocol – Liga Feb 07 '20 at 06:16
  • @Liga - fair point, clarified. – Useless Feb 07 '20 at 11:24
  • 1
    @Niing - absolutely not. The URI scheme is "urn". _Everything_ after the first colon is interpreted according to the [URN scheme](https://tools.ietf.org/html/rfc8141#section-2) - you can see that "isbn" in your example is a **Namespace Identifier**. – Useless Feb 07 '20 at 11:28
  • So the scheme doesn't actually do anything? It's just a suggestion that the user or browser can choose to follow o not. For example, if I send an MQTT message to an htt p://somesite.com url, nothing is actually going to check that my message isn't http, and it's going to be sent as is. – Juan Perez Jun 02 '23 at 00:05
  • It's a short character string prefix, of course it doesn't "do" anything. It's up to your MQTT client to validate the URIs you give it, if it makes sense to. – Useless Jun 02 '23 at 13:31
9

The quote from Wikipedia may be a bit misleading. What it means is that for example the file: URI scheme does not state what kind of way is used to accessing the data (or whatever it is pointing to). With http: you know there is the HTTP protocol being used. With file: it's whatever the applications wants to use.

With news: the protocol name is NNTP, but the name doesn't reflect that. Which is a good thing in my mind, since news: is a lot clearer.

So the URI scheme is just the first part including the colon.

Sami Kuhmonen
  • 193
  • 1
  • 8
2

The scheme indicates the addressing system used. URL's are really a unification of various disparate addressing systems. The part before the colon identifies the scheme in use, and everything after the colon is syntax specific for the scheme. Each scheme defines its own unique way of addressing resources. This makes the URL standard infinitely extensible through adding new schemes.

It is hard to say anything in general for schemes, because they are wildly different. In many cases the name of the scheme is the name of a protocol which can be used to fetch the resource (like http, https, ftp etc.) but that is not a hard rule, eg. the 'mailto' scheme indicates an e-mail address, but not a particular protocol. Some schemes don't correspond to any specific protocol, like the 'about' scheme used in web browsers, where the resource is not fetched via a protocol, but is built-in in the client.

Mehdi Charife
  • 258
  • 1
  • 12
JacquesB
  • 57,310
  • 21
  • 127
  • 176
1

It's the part before the colon in a URI.

For example: the scheme for http://en.wikipedia.org/ is http. The scheme for file:///etc/passwd is file. The scheme for ftp://example.org/resource.txt is ftp.

user253751
  • 4,864
  • 3
  • 20
  • 27
  • This is really the best answer for end users. When I am explain the web to new users and young kids, they understand immediately. – benc May 29 '23 at 22:59
1

I like Apple's description:

A URL scheme is the part of a link that specifies the type of application your device uses to open a URL. Many apps support URL schemes: FaceTime uses URL schemes to make calls when a URL starting with facetime:// is opened, just like Safari handles URLs starting with http://.

Shortcut’s URL scheme, shortcuts://, launches the Shortcuts app from a link to perform a task such as importing or running a shortcut. These links can be useful in many different contexts such as on the web or when using Shortcuts with other apps that support opening URLs

Source

CrazyTim
  • 113
  • 5
  • I regret to observe that Apple has documented some, but not all of the URL schemes they use in their various OS variants. Also, some of the URL schemes they use do not seem to be registered with IANA. But they are not the only vendor that does this, GIT vendors seem to think that using git@: is a valid scheme. It pretty much isn't, according to https://www.rfc-editor.org/rfc/rfc2717 – benc May 29 '23 at 22:58
0

The scheme is the first hierarchy of an URI and therefore the most 'prominent' part, which is used to identify the 'purpose' of the resource. If you are interested in some 'kind' of resource (web links, news, files), you can tell by just using checking the scheme - not the whole resource string.

It's just a string repesenting a set of resources.

TMS
  • 125
  • 4