Represents the URL hostname (e.g., "example.com").
'port'
Represents the URL port (e.g., "8080").
'query'
Represents URL query parameters as an object.
'path'
Represents the URL path.
set(key,value)
const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
url.set('hostname', 'google.com')
console.log(url.toString())
//http://google.com:8080/3rd-Eden/path/to/resource?name=John&id=123#section2
Parameter
Description
key
A string literal representing the property to be set. Valid options include: 'hash', 'protocol', 'origin', 'username', 'password', 'hostname', 'port', 'query', or 'path'.
value
The value to set for the specified property. It can be either a string or an object(query) with string keys and any values.