Seven parts make a URL
Scheme, credentials, host, port, path, query string and fragment. In https://www.example.com:8080/search?q=hello&lang=zh#section the scheme is https, host www.example.com, port 8080, path /search, query pairs q and lang, fragment section. Fragments never reach the server, which contradicts a common belief. Omitted ports imply scheme defaults — 443 for https, 80 for http.
Steps
- Paste a full URL, and the sample already carries port, query and fragment.
- Parse to list scheme, host, port, path, parameters and fragment.
- Query pairs split by key, with repeats and empties listed separately.
- Load the sample or clear.
- When comparing, check field by field rather than the raw string.
Query encoding rules
Queries cannot hold raw spaces, Chinese, ampersands or equals signs; percent-encoding applies. Spaces become percent-two-zero, Chinese is UTF-8 byte-encoded then escaped. Decoding must restore them or parameters read as mojibake. A plus sign means space in a query but not in a path — a common form-submission trap. Parameter order usually carries no meaning, except where signatures define it, and then it must be preserved exactly.
Relative paths and normalisation
Browsers resolve relatives against a base and collapse dot segments, so a parent reference simplifies away. A trailing slash differs: some servers redirect when it is missing. Percent-encoded equivalents such as tilde forms complicate comparison, and authorisation checks must compare parsed values, never raw strings.
Security parsing traps
Prefix checks on the domain fall to example.com.evil.net; extract the host and compare whole labels. Credentials before the host mean example.com@evil.net actually points at evil.net. Double encoding defeats a single decode pass. Some browsers normalise backslashes to slashes, changing what you parse. And an explicit default port is semantically equal to an omitted one while string comparison says otherwise.
When a parser earns its keep:It speeds up tracing redirect chains, auditing callback allow-lists, checking whether tracking parameters survive, and diagnosing signature mismatches. Security checks need a standard parser rather than hand-written regex, with decisions made after parsing. Across languages, tolerance for malformed URLs differs, so one input can yield different hosts in a browser and a shell — a risk in itself.