Docs

URL.prototype.toString

Returns the URL as a string.

Example

let url = new URL("https://example.com/path?foo=bar")
url.toString()
"https://example.com/path?foo=bar"
let url = new URL("https://[email protected]:8080")
url.toString()
"https://[email protected]:8080/"
let url = new URL("https://example.com")
url.pathname = "/new"
url.toString()
"https://example.com/new"