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

  1. 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.
  2. Enter url using the field table and calculation rules, then run the tool.
  3. Read port. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
urlAbsolute URL to parse.string; maximum length: 1000000Required

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 fieldMeaningValue type
portNormalized URL port.string; maximum length: 1000000
json
{
  "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

  1. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies