Object UrlObject
Url processing object
Basic module. supplyurl Formatting, parsing and assembling
1
2
3
4
5
6var url = new net.Url('http://www.xici.net/');
var url = new net.Url({
protocol: 'http:',
hostname: 'www.xici.net',
pathname: '/'
});
Inheritance
Constructor
UrlObject
UrlObject object constructor, using parameter construction
1new UrlObject(Object args);
Call parameters:
- args: Object, the dictionary object that specifies the construction parameters. The supported fields are: protocol, slashes, username, password, hostname, port, pathname, query, hash
UrlObject object constructor, use url String construction
1
2
3new UrlObject(String url = "",
Boolean parseQueryString = false,
Boolean slashesDenoteHost = false);
Call parameters:
- url: String, specified structure url String
- parseQueryString: Boolean, specify whether to parse the query
- slashesDenoteHost: Boolean, default is false, if set to true, the string from after the string'//' to the next'/' will be parsed as host, for example,'//foo/bar', the result should be { host:'foo', pathname:'/bar') instead of {pathname:'//foo/bar'}
Member attributes
href
String, query and set the integrity of the current UrlObject object url Address description, this description is assembled from all other attributes
1String UrlObject.href;
protocol
String, query and set the protocol name in the current UrlObject object
1String UrlObject.protocol;
slashes
Boolean, query and set whether the current UrlObject object contains double slashes
1Boolean UrlObject.slashes;
auth
String, query and set the complete verification string in the current UrlObject object, assembled by the username and password attributes
1String UrlObject.auth;
username
String, query and set the authenticated user in the current UrlObject object
1String UrlObject.username;
password
String, query and set the authentication password in the current UrlObject object
1String UrlObject.password;
host
String, query and set the complete host description in the current UrlObject object, assembled by hasname and port
1String UrlObject.host;
hostname
String, query and set the host name in the current UrlObject object
1String UrlObject.hostname;
port
String, query and set the port number in the current UrlObject object
1String UrlObject.port;
path
String, query and set the full path of the request in the current UrlObject object (including the request), assembled by pathname and query
1String UrlObject.path;
pathname
String, query and set the path in the current UrlObject object
1String UrlObject.pathname;
search
String, query and set the request string (including "?") in the current UrlObject object, which is equivalent to "?"+query
1String UrlObject.search;
query
Value, query and set the request string in the current UrlObject object (without "?")
1Value UrlObject.query;
hash
String, query and set the request anchor point in the current UrlObject object (including "#")
1String UrlObject.hash;
searchParams
HttpCollection, Query the request string in the current UrlObject object (without "?")
1readonly HttpCollection UrlObject.searchParams;
Member function
parse
Parse one url String
1
2
3UrlObject.parse(String url,
Boolean parseQueryString = false,
Boolean slashesDenoteHost = false);
Call parameters:
- url: String, specify what needs to be parsed url String
- parseQueryString: Boolean, specify whether to parse the query
- slashesDenoteHost: Boolean, default is false, if set to true, the string from after the string'//' to the next'/' will be parsed as host, for example,'//foo/bar', the result should be { host:'foo', pathname:'/bar') instead of {pathname:'//foo/bar'}
format
Construct UrlObject with specified parameters
1UrlObject.format(Object args);
Call parameters:
- args: Object, the dictionary object that specifies the construction parameters. The supported fields are: protocol, slashes, username, password, hostname, port, pathname, query, hash
resolve
reset url Path, automatically recognize whether the new path is a relative path or an absolute path
1UrlObject UrlObject.resolve(String url);
Call parameters:
- url: String, specify a new path
Return result:
- UrlObject, Returns an object containing relocation data
normalize
Standardized path
1UrlObject.normalize();
toString
Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics
1String UrlObject.toString();
Return result:
- String, Returns the string representation of the object
toJSON
Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object
1Value UrlObject.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable