Skip to content

Invalid URL on IPv6 http.RequestOptions.host without square brackets #21864

@sgvictorino

Description

@sgvictorino

Version: Deno 1.39.3

Whether IPv6 hostnames should have square brackets when passed to http.request(options: RequestOptions) seems to be reversed from Node:

const { request } = await import("node:http")
request({ host: "[::1]" }).end() // Node throws at getaddrinfo
request({ host: "::1" }).end() // Deno uses the URL constructor:
/* Uncaught TypeError: Invalid URL: 'http://::1/'
    at getSerialization (ext:deno_url/00_url.js:90:11)
    at new URL (ext:deno_url/00_url.js:381:27)
    at ClientRequest._createUrlStrFromOptions (node:http:585:17)
    at ClientRequest._writeHeader (node:http:385:22)
    at ClientRequest._send (ext:deno_node/_http_outgoing.ts:405:12)
    at ClientRequest.end (node:http:441:12) */

Metadata

Metadata

Assignees

No one assigned

    Labels

    node APIRelated to various "node:*" modules APIsnode compat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions