Last active
January 5, 2024 11:09
-
-
Save dmail/54677cc3eae1661813e3a87840666f83 to your computer and use it in GitHub Desktop.
URL parts naming. Inspired from web browsers API (new URL(), window.location) and rfc3986.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
href | |
┌────────────────────────────────────────┴──────────────────────────────────────────────┐ | |
origin │ | |
┌────────────┴──────────────┐ │ | |
│ authority │ | |
│ ┌───────────────┴───────────────────────────┐ │ | |
│ │ host resource | |
│ │ ┌──────────┴─────────────────┐ ┌────────────┴───────────┬───────┐ | |
│ │ hostname │ pathname │ │ | |
│ │ ┌──────────────┴────────────┐ │ ┌──────┴───────┐ │ │ | |
protocol userinfo subdomain domain │ │ filename │ │ | |
┌─┴──┐ ┌───┴────┐ │ ┌────────┴───────┐ │ │ ┌───┴─────┐ │ │ | |
scheme │username password lowerleveldomains secondleveldomain topleveldomain port dirname basename extension search hash | |
┌──┴───┐│┌──┴───┐ ┌──┴───┐ ┌──┬─┬─┴─────┬───┐┌───────┴───────┐ ┌──────┴──────┐┌─┴┐┌────┴──────┐┌──┴───┐ ┌───┴───┐ ┌────┴────┐ ┌┴┐ | |
│ │││ │ │ │ │ │ │ │ ││ │ │ ││ ││ ││ │ │ │ │ │ │ │ | |
scheme://username:[email protected]:1234/hello/world/basename.extension?name=ferret#hash | |
*/ |
nits:
s/ressource/resource/
It's updated 👍
@dmail Sorry, your document is based on "Location" and not on URL. Please ignore my point.
I have added "Inspired from web browsers API (new URL(), window.location) and rfc3986." to the description 👍
A more detailed description about this gist.
I have created this gist to list and identify all urls parts.
The names are meant to name JavaScript variables or identify what a JavaScript variable refers to.
For this reason names are coming first from URL Web API. Then all blanks left by URL web API are filled using rfc3986.
It results in the 2 differences mentioned in gistcomment-4251501
- "search" from web APIs is favored over "query" from rfc3986
- "hash" from web APIs is favored over "fragment" from rfc3986
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dmail Sorry, your document is based on "Location" and not on URL. Please ignore my point.
https://developer.mozilla.org/ja/docs/Web/API/Location