urlObject object properties
All property specifications use the urlObject object. When omitted, the urlObject object is assumed to be initialized. The urlObject can be returned by the url.parse() API.
urlObject.auth
Indicates the username and password portion of a URL.
- Syntax
urlObject.auth
- Guidelines
- The urlObject.auth property indicates the username and password portion of
the URL, also referred to as
userinfo
. The value of the urlObject.auth property is a string of the{username}[:{password}]
format, where the[:{password}]
portion can be omitted. For example,'user:pass'
.
urlObject.hash
Indicates the fragment portion of a URL.
- Syntax
urlObject.hash
- Guidelines
- The urlObject.hash property indicates the fragment portion of a URL that
includes the leading ASCII hash (#) character. For example, the returned value of the
urlObject.hash property is
'#hash'
.
urlObject.host
Indicates the full lowercase host component of a URL.
- Syntax
urlObject.host
- Guidelines
- The urlObject.host property indicates the full lowercase host portion of the
URL, including the port if specified. For example, the returned value of the
urlObject.host property is
'sub.host.com:8080'
.
urlObject.hostname
Indicates the lowercase hostname portion of the host component without the port of a URL.
- Syntax
urlObject.hostname
- Guidelines
- The urlObject.hostname property indicates the lowercase hostname portion of
the host component without the port. For example, the returned value of the
urlObject.hostname property is
'sub.host.com'
.
urlObject.href
Indicates the full lowercase URL string that is parsed with both the protocol and host components.
- Syntax
urlObject.href
- Guidelines
- The urlObject.href property indicates the full lowercase URL string that is
parsed with both the protocol and host components. For example, the returned value of the
urlObject.href property is
'http://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'
.
urlObject.path
Indicates a concatenation of the path name and search components of a URL.
- Syntax
urlObject.path
- Guidelines
- The urlObject.path property indicates a concatenation of the path name and
search components of a URL. For example, the returned value of the urlObject.path
property is
'/p/a/t/h?query=string'
. The path is not decoded.
urlObject.pathname
Indicates the entire path section of the URL.
- Syntax
urlObject.pathname
- Guidelines
- The urlObject.pathname property indicates the entire path section of the URL,
which is everything that follows the host-port and before the start of the query (?) or hash (#)
components. For example, the returned value of the urlObject.pathname property is
'/p/a/t/h'
. The path string is not decoded.
urlObject.port
Indicates the port portion of the host component of a URL.
- Syntax
urlObject.port
- Guidelines
- The urlObject.port property indicates the port portion of the host component
of a URL. For example, the returned value of the urlObject.port property is
'8080'
.
urlObject.protocol
Indicates the lowercase protocol scheme of a URL.
- Syntax
urlObject.protocol
- Guidelines
- The urlObject.protocol property indicates the lowercase protocol scheme of a
URL. For example, the returned value of the urlObject.protocol property is
'http:'
.
urlObject.query
Indicates the query string without the leading ASCII question mark (?
) or an
object that is returned by the urlObject.parse API in the query string
module.
- Syntax
urlObject.query
- Guidelines
- The urlObject.query property indicates either the query string without the
leading ASCII
?
or an object that is returned by the querystring.parse() API in the query string module. Whether the urlObject.query property is a string or an object is determined by theparseQueryString
parameter that is passed to the url.parse() API.- If the returned value of the urlObject.query property is a string, the query string is not decoded.
- If the returned value of the urlObject.query property is an object, both object name and value are decoded.
For example, the returned value of the urlObject.query property can be the
'query=string'
string or the{'query': 'string'}
object.For more information, see querystring module.
urlObject.search
Indicates the entire query string portion of a URL.
- Syntax
urlObject.search
- Guidelines
- The urlObject.search property indicates the entire query string portion of a
URL that includes the leading ASCII question mark (?) character. For example, the returned value of
the urlObject.search property is
'?query=string'
. The query string is not decoded.
urlObject.slashes
Controls whether the protocol needs two forward slashes after the colon in the provided URL.
- Syntax
urlObject.slashes
- Guidelines
- The urlObject.slashes property is a Boolean that controls whether the
protocol needs two forward slashes (
//
) after the colon (:
) in the provided URL. The value istrue
when the protocol dictates that the colon must be followed by two forward slashes (://
). Otherwise, the value isfalse
.