[whatwg/url] Strictness on Port doesn't conform to URL/URI RFCs (Issue #883)

TechnicallyWeb3 created an issue (whatwg/url#883)

### What is the issue with the URL Standard?

According to my research the RFC 793 related to TCP/IP does have a port specification of 16 bits. However, I don't see this restriction in any URL specific RFCs (1738/3986). 

The only spec I see for port numbers is that they must use digits [RFC 3986#3.2.3](https://www.rfc-editor.org/rfc/rfc3986#section-3.2.3). 

I have been trying to work with a new type of URL/URI to be used in blockchain networks. A simple path would look like this:

`wttp://tw3.eth/` or `wttp://tw3.eth:137/`

The full URL scheme I intend to use looks like this:

`wttp://0xDA00006427E534B1Acde93B9E66d8A9d2C66B2d3:0xeb72e700fb2b9ac2c70814a32192ddf011fb27222b21491245d784be8e2c6de021734ce1c2771b2d59b4406e5bac0213a6995fce7caf807e11ef3d6681d4203d1c           @0xe254f0797ed59ce23485e23cf07c24b3bcf02407:137/path/index.html?param=value&param2=value2#anchor`

Which breaks down as such:

`wttp://[[userAddress][:userSignature]@][contractAddress/domainName][:chainId]/[path][...standard URL queries&hash]`

I am having several issues with the WHATWG standard. Namely for this topic the chain ID. When working with EVM chain identifiers there's a much larger bit space for chain IDs. When using the native URL class in js/ts I encounter the issue that my URLs are invalid. This prompted me to build an extended wURL library in my protocol's core package. You can find my workaround here: [wttp-core/src/utils/wurl.ts](https://github.com/TechnicallyWeb3/wttp-core/blob/main/src/utils/wurl.ts). You may note I am also using string aliases here for our user's ease. Please ignore this since our original goal was to have our wttp handler transform this to a numeric chain ID before becoming a URL. We want our protocol to follow URL Standards. 

What would be much easier than our chainId workaround is if WHATWG supported larger port numbers than the 16-bit port number limit. If a limit is needed might I suggest uint64 or higher to accommodate ethereum chainIds or other custom, protocol-specific values. This will allow the individual protocols to determine which port numbers are valid on their own and not be limited by URL Standards (especially since it's not actually part of the URL scope).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/883
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/883@github.com>

Received on Thursday, 2 October 2025 19:04:57 UTC