Deno: URL parser does not handle IPv6 URLs

Created on 22 May 2020  路  1Comment  路  Source: denoland/deno

Currently the URL parser can handle hostnames, IP addresses, etc.

> new URL('http://127.0.0.1')
URL { href: "http://127.0.0.1/", origin: "http://127.0.0.1", protocol: "http:", username: "", password: "", host: "127.0.0.1", hostname: "127.0.0.1", port: "", pathname: "/", hash: "", search: "" }

Unfortunately, when using IPv6 addresses in URLs, the hostname is parsed as [, which means the remaining part is treated as a port (and therefore invalid)

> new URL('http://[::1]')
Uncaught TypeError: Invalid URL.
    at new URLImpl ($deno$/web/url.ts:418:13)
    at <unknown>:1:1
    at evaluate ($deno$/repl.ts:45:34)
    at Object.replLoop ($deno$/repl.ts:136:13)

This has also caused an (uncaught) error in Oak when a URL is accessed by IPv6 address directly, and the same may be true for other applications.

bug

Most helpful comment

Will submit a PR shortly

>All comments

Will submit a PR shortly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

justjavac picture justjavac  路  3Comments

ry picture ry  路  3Comments

doutchnugget picture doutchnugget  路  3Comments

ry picture ry  路  3Comments

zugende picture zugende  路  3Comments