This is the 14th day of my participation in the August More Text Challenge

Recently I am doing the front end test summary series, interested friends can add attention, welcome to correct, exchange.

Strive for each knowledge point can sum up some more, at least to do in the interview, for each knowledge point can kan up, not dumb fire.

The introduction

How many of you can’t tell the difference between a URL and a URI like me?

To my shame, I always thought THAT URL and URI were the same, so I often used them together when calling them. When I accidentally learned that they were two different concepts, my state was like this:

In one word: shame! It might be fine if you were ignorant all the time, but once you know the truth, you’ll wonder if you didn’t know it because of the joke… The past cannot bear to recall! To avoid possible future mishaps, these two concepts must be understood!

URL

concept

Uniform Resource Locator (Uniform Resource Locator), which identifies the location of network resources.

A URL is the address of a resource on the Internet and can be defined as a string referencing the address that indicates the location of the resource and the protocol used to access it.

Urls are the most commonly used way to locate resources on a network, providing a way to retrieve a representation of a physical location by describing its network location or primary access mechanism.

The protocol is described in the URL for retrieving resources and resource names. If the resource is a Web resource, the URL starts with HTTP/HTTPS. Similarly, if the resource is a file, it starts with FTP, and if the resource is an E-mail address, it starts with Mailto.

composition

The URL contains the following information:

  • The protocol used to access resources
  • The location of the server (whether by IP address or domain name)
  • Port number on the server (optional)
  • Location of a resource in the server directory structure
  • Segment identifier (optional)

Such as:

https://juejin.cn/user/2893570333750744/posts
Copy the code

role

Urls are mainly used to link web pages, web components or programs on web pages, and use access methods (HTTP, FTP, Mailto and other protocols) to retrieve location resources.

URI

concept

Uniform Resource Identifier, or Uniform Resource Identifier, is used to identify an abstract or physical Resource.

A URI is a sequence of characters that identifies a logical or physical resource. Similar to a URL, a URI is a string of characters. It allows for uniform identification of resources by using location, name, or both to identify resources on the Internet.

There are two types of URIs, Uniform Resource Identifiers (urls) and Uniform Resource Names (UrNs).

composition

The general form of any URI is:

The scheme:// [user: password @] host [: port]] [/] path [? Query] [# fragment]
Copy the code

Among them:

  • Scheme: This Scheme lists any associated protocols for specific syntax and URIs. The scheme is case insensitive, followed by a colon. Ideally, URI schemes should be registered with the Internet Assigned Numbers Authority (IANA), but unregistered schemes can also be used.
  • Permission component: The permission component consists of several parts: an optional authentication part, a host (consisting of a registered name or IP address), and an optional port number. The authentication section contains the username and password, separated by a colon and followed by an AT (@) symbol. After the @ is the host name, then a colon, then a port number. It is important to note that IPv4 addresses must be in dotted decimal notation and IPv6 addresses must be enclosed in parentheses.
  • Query (Optional) : A query contains a string of non-hierarchical data. Although the syntax is not clearly defined, it is usually a sequence of attribute value pairs separated by delimiters, such as ampersand or semicolon. The query is separated from the previous part by a question mark.
  • Fragments (optional) : Fragments contain fragment identifiers that provide direction for secondary resources.

role

Uris are used to define project identifiers, where word identifiers indicate that one resource is to be distinguished from others regardless of the method used (URL or URN).

conclusion

Through the above LEARNING of URL and URI contents, the summary is as follows:

  • The URL specifies the type of protocol to use, while the URI does not address the protocol specification.
  • You can say that a URL is a URI (because a URL is a subset of a URI), but a URI can never be a URL.

~

Thanks for reading!

~

Learn interesting knowledge, meet interesting friends, shape interesting soul!

Hello everyone, I am the author of “programming Samadhi”, I am king Yi, my public account is “programming Samadhi”, welcome to pay attention, I hope you can give me more advice!

You come, with expectations, I have ink to welcome! You return, no matter gain or loss, only to yu Yun give each other!

Knowledge and skills should be paid equal attention to, internal force and external power should be repaired simultaneously, theory and practice should grasp both hands, both hands should be hard!