…
This is a simple tool to parse a URL into the different components,
SCHEME, HOST, PORT, USER, PASS, PATH, QUERY or FRAGMENT. It incorporates a technique for parsing URLs into parts.
A URL string is a structured string containing multiple meaningful components. When parsed, a URL object is returned containing properties for each of these components.
[protocol:][//host[:port]][path][?query][#fragment]
The query string portion of a dynamic URL contains the search parameters. It parses the string into variables with each parameter being a property.
This function is not meant to validate the given URL, it only breaks it up into the above listed parts.
| request ----------------------------------------------- | | path ------------------- | | | authorization | | domain -------------- | | directory ---- || file - | | query ---------------- | | | | | | | || | | | | https://username:password@www.subdomain.example.com:1234/folder/subfolder/index.html?search=products&sort=false#top | | | | | | | | | | | | | | | | | | username | | | | | | folder folder | | | value | value | protocol password | | | | port | | parameter parameter | | | | 1st-level-domain | file-extension fragment | | 2nd-level-domain filename | 3rd-level-domain 4th-level-domain
Commenting your code is like cleaning your bathroom you never want to do it, but it really does create a more pleasant experience for you and your guests.
Ryan Campbell
…
…