liveBook · Manning

URL

As explained in Vanilla Web

A URL is a standardized textual address that identifies a web resource or navigation destination and can include protocol, host, port, path, query, and fragment components.

A URL identifies a web resource or navigation destination. It is also part of an app’s user experience: a readable URL is easier to trust, share, bookmark, and use as a deep link. section 2.1.2 section 2.3.3

The parts of a URL have different jobs:

  • The protocol, host, and port identify an origin, which is a browser security boundary. A different origin is cross-origin; a different registrable domain is cross-site. section 2.1.2
  • The path identifies a location within the host. A query after ? carries key/value parameters, such as ?id=1&sort=asc. section 2.1.2
  • A fragment after # can target a place in a document. A text fragment beginning #:~:text= can highlight specific text. section 2.1.2

Read a URL

In https://firt.dev/notes/pwa#android, HTTPS is the protocol, firt.dev is the host, 443 is the implicit port, /notes/pwa is the path, and android is the fragment. section 2.1.2

For application routes, use descriptive paths and put shareable UI state in the query string when needed. Reserve the hash for document fragments rather than primary routing. Represent internal destinations with real <a href> links so they remain accessible, crawlable, bookmarkable, and easy to open in a new tab. If an app handles navigation on the client, its server must still return the entry HTML for valid deep links without swallowing asset requests, API requests, or real 404 responses. section 10.5

How Vanilla Web covers it

How deep it goes
Defines URL components and gives routing rules, but defers construction of a complete router.
Examples
Decomposes an HTTPS URL with a path and fragment, and illustrates query parameters with ?id=1&sort=asc.
What it assumes
Introduces URL components from definitions while assuming a web-app context for the routing guidance.
What you can do after
Apply it to design shareable routes and distinguish URL parts that affect security, navigation, and UI state.
How it connects
Connects URLs to origins, cross-site security, deep links, query strings, document fragments, and client-side routing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vanilla Web. The section links point to the parts of the book it draws on.