The url
module supports URL parsing and formatting. Use require('url')
to access this module.
A URL string is a structured string containing multiple meaningful components. For example https://user:[email protected]:8080/p/a/t/h?query=string#hash
is consists of below components:
protocol: https:
username: user
password: pass
hostname: sub.example.com
port: 8080
pathname: /p/a/t/h
search: ?query=string
hash: hash
input
<string>
Creates a URL object by parsing the input string.
<string>
Gets and sets the fragment portion of the URL.
<string>
Returns readonly host portion of the URL.
<string>
Gets and sets the hostname portion of the URL.
<string>
Returns serialized URL string.
<string>
Returns readonly origin portion of the URL.
<string>
Gets and sets the password portion of the URL.
<string>
Gets and sets the pathname portion of the URL.
<string>
Gets and sets the port portion of the URL.
<string>
Gets and sets the protocol portion of the URL.
<string>
Gets and sets the search string portion of the URL.
<URLSearchParams>
Returns URLSearchParams object constructed from search
property.
<string>
Gets and sets the username portion of the URL.
Returns: <string>
Returns serialized URL string.
Returns: <string>
Returns serialized URL string.
This class allows to read and write access to the query string of a URL.
input
<string>
A query string
Parses the input query string. A leading '?'
characters is ignored.
name
<string>
value
<string>
Append a name-value pair.
name
<string>
Delete all name-value pairs whose name is name
.
Returns: <Array>
Returns all name-value pairs as an array.
name
<string>
Returns: <string>
Returns the value of first name-value pairs whose name is name
.
name
<string>
Returns: <string[]>
Returns the values of all name-value pairs whose name is name
.
name
<string>
Returns: <boolean>
Returns true
if there is at least one of name-value pair whose name is name
.
Returns: <string[]>
Returns all names of all name-value pairs.
name
<string>
value
<string>
Set the value of first name-value pair and deletes all other name-value pairs whose name is name
. If not exists, append a name-value pair.
Returns: <string[]>
Returns all values of all name-value pairs.
Returns: <string>
Serializes and returns a query string from all name-value pairs with percent encoding.