Skip to content

static: URL.port and URL.hash have no lowering (not-implemented) #372

Description

@HagegeR

Summary

The static URL lowering supports protocol, pathname, href, host, hostname, search, searchParams and toString() (per the compiler hint), but port and hash are not-implemented in node-v24-internal.json. Both are needed to validate that a URL is exactly <scheme>://<host>[:port]/<path> with no fragment, which is a typical allow-list check for loopback broker or callback URLs.

Reproduction

// url.ts
const url = new URL("https://example.com:8443/path#frag");
console.log(url.port, url.hash);
$ node --experimental-strip-types url.ts
8443 #frag
$ scriptc build -o /tmp/r url.ts
url.ts:2:13 - error SC2020: 'URL.port' is typed by @types/node but has no scriptc lowering yet
1 error.

With url.port removed the same file reports 'URL.hash' is typed by @types/node but has no scriptc lowering yet. Without a tsconfig.json the ambient URL type lacks both properties (Property 'port' does not exist on type 'URL').

Expected

WHATWG semantics as in Node: port is "" when the port is the scheme default or absent, otherwise the decimal string; hash is "" when there is no fragment, otherwise "#" plus the fragment. Read-only getters are sufficient for my use; setters are a separate ask.

Tier

Static. I have not checked whether the dynamic island exposes them; the request is for the static lowering only.

Related

Open PR #249 adds a URL.port getter extraction; URL.hash is not covered there.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions