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, aBufferis returned. - url.format()
The
url.format()method returns a formatted URL string derived fromurlObject. - url.pathToFileURL()
This function ensures that
pathis 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()andhttps.request()APIs.
Classes 1
Interfaces 14
- interface FileUrlToPathOptions
- interface PathToFileUrlOptions
- interface Url
- interface URL
- interface URLFormatOptions
- interface UrlObject
- interface URLPatternComponentResult
- interface URLPatternInit
- interface URLPatternOptions
- interface URLPatternResult
- interface URLSearchParams
- interface URLSearchParamsIterator
- interface UrlWithParsedQuery
- interface UrlWithStringQuery