URL Port
Extract the port of an absolute URL using the WHATWG URL parser, including its normalization rules.
Description
A URL port identifies an endpoint within a host.
A URL port identifies an endpoint within a host. The serialized property omits a scheme's default port, so an empty result can reflect either omission or normalization.1
Extract the port of an absolute URL using the WHATWG URL parser, including its normalization rules.
When to use URL Port
Use this tool to extract the port of an absolute URL using the WHATWG URL parser, including its normalization rules.
Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.
How to use URL Port and understand its results
- Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.
- Enter url using the field table and calculation rules, then run the tool.
- Read port. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| url | Absolute URL to parse. | string; maximum length: 1000000 | Required |
Paste an absolute URL. Return a string for an explicit nondefault port; omitted or default ports yield an empty string, such as :443 on HTTPS. Invalid port syntax or a malformed URL gives an input error.
port=WHATWG_URL(url).port Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| port | Normalized URL port. | string; maximum length: 1000000 |
{
"input": {
"url": "https://reader:secret@EXAMPLE.com:8443/a/../guide?q=one&q=two#part"
},
"output": {
"port": "8443"
}
} Limitations and assumptions
The output is serialized text, not an effective numeric default port. No service discovery, listening-port check or connection test is performed.
Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use URL Host: Extract the host of an absolute URL using the WHATWG URL parser, including its normalization rules. For a complementary task, use URL Protocol: Extract the protocol of an absolute URL using the WHATWG URL parser, including its normalization rules.
References
-
URL Port — tool.io
Similar or alternative tools
- URL Host
Extract the host of an absolute URL using the WHATWG URL parser, including its normalization rules.
- URL Protocol
Extract the protocol of an absolute URL using the WHATWG URL parser, including its normalization rules.