Node.js module

url

The 'node:url' module provides utilities to parse, format, and resolve URLs. It includes the URL and URLSearchParams classes that conform to the WHATWG URL specification.

Features include protocol, hostname, pathname, query string parsing, and manipulation, allowing robust URL handling in network applications.

Fully supported in Bun

Fully implemented.

Functions 7

  • url.domainToASCII()

    Returns the Punycode ASCII serialization of the domain.

  • url.domainToUnicode()

    Returns the Unicode serialization of the domain.

  • url.fileURLToPath()

    This function ensures the correct decodings of percent-encoded characters as well as ensuring a cross-platform valid absolute path string.

  • url.fileURLToPathBuffer()

    Like url.fileURLToPath(...) except that instead of returning a string representation of the path, a Buffer is returned.

  • url.format()

    The url.format() method returns a formatted URL string derived from urlObject.

  • url.pathToFileURL()

    This function ensures that path is resolved absolutely, and that the URL control characters are correctly encoded when converting into a File URL.

  • url.urlToHttpOptions()

    This utility function converts a URL object into an ordinary options object as expected by the http.request() and https.request() APIs.

Classes 1

Interfaces 14

Types 1

Variables 2