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 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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