Skip to content

parsePort

parsePort(text): PortNumber

Defined in: packages/net-address/src/port/port.ts:65

Parses a decimal port number, strictly: digits only, no sign, no leading zero, no whitespace.

A leading zero is rejected for the same reason parseIpv4Address rejects it — 080 must not read as 80 here and as something else in the next hop’s parser. O(1).

string

PortNumber

NetAddressSyntaxError When text is not such a number, or is out of range.