Object built-in object

Object UrlObject

Url object

Basic modules. Provide url formatting, parsing and assembly

1 2 3 4 5 6
var 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, constructed with parameters

1
new UrlObject(Object args);

Call parameters:

  • args : Object, a dictionary object specifying the construction parameters. The supported fields are: protocol, slashes, username, password, hostname, port, pathname, query, hash

UrlObject object constructor, constructed using a url string

1 2 3
new UrlObject(String url = "", Boolean parseQueryString = false, Boolean slashesDenoteHost = false);

Call parameters:

  • url : String, specify the structure url string
  • parseQueryString : Boolean, specifies whether to parse query
  • slashesDenoteHost : Boolean, default is false, if set to true, the string from the string '//' to the next '/' will be parsed as host, such as '// foo / bar', the result should be {host: 'foo', pathname: '/ bar'} instead of {pathname: '// foo / bar'}

Member attributes

href

String, query and set the full url description in the current UrlObject object, this description is assembled from all other properties

1
String UrlObject.href;

protocol

String, query and set the protocol name in the current UrlObject object

1
String UrlObject.protocol;

slashes

Boolean, query and set whether the current UrlObject object contains double slashes

1
Boolean UrlObject.slashes;

auth

String, query and set the full validation string in the current UrlObject object, assembled from the username and password attributes

1
String UrlObject.auth;

username

String, query and set the authenticated user in the current UrlObject object

1
String UrlObject.username;

password

String, query and set the authentication password in the current UrlObject object

1
String UrlObject.password;

host

String, query and set the full host description in the current UrlObject object, assembled from hastname and port

1
String UrlObject.host;

hostname

String, query and set the host name in the current UrlObject object

1
String UrlObject.hostname;

port

String, query and set the port number in the current UrlObject object

1
String UrlObject.port;

path

String, query and set the complete path (including the request) of the request in the current UrlObject object, assembled from pathname and query

1
String UrlObject.path;

pathname

String, query and set the path in the current UrlObject object

1
String UrlObject.pathname;

String, query and set the request string (including "?") In the current UrlObject object, equivalent to "?" + Query

1
String UrlObject.search;

query

Value, query and set the request string (excluding "?") In the current UrlObject object

1
Value UrlObject.query;

hash

String, query and set the request anchor (including "#") in the current UrlObject object

1
String UrlObject.hash;

Member function

parse

Parse a url string

1 2 3
UrlObject.parse(String url, Boolean parseQueryString = false, Boolean slashesDenoteHost = false);

Call parameters:

  • url : String, specifies the url string to be parsed
  • parseQueryString : Boolean, specifies whether to parse query
  • slashesDenoteHost : Boolean, default is false, if set to true, the string from the string '//' to the next '/' will be parsed as host, such as '// foo / bar', the result should be {host: 'foo', pathname: '/ bar'} instead of {pathname: '// foo / bar'}

format

Constructs a UrlObject with the specified parameters

1
UrlObject.format(Object args);

Call parameters:

  • args : Object, a dictionary object specifying the construction parameters. The supported fields are: protocol, slashes, username, password, hostname, port, pathname, query, hash

resolve

url path and automatically identify whether the new path is relative or absolute

1
UrlObject UrlObject.resolve(String url);

Call parameters:

  • url : String, specifying the new path

Returns the result:

  • UrlObject , returns an object containing relocation data

normalize

Standardized path

1
UrlObject.normalize();

toString

Returns a string representation of the object, usually "[Native Object]". Objects can be reimplemented according to their own characteristics

1
String UrlObject.toString();

Returns the result:

  • String , returns a string representation of the object

toJSON

Returns a JSON representation of the object, typically returning a collection of readable properties defined by the object

1
Value UrlObject.toJSON(String key = "");

Call parameters:

  • key : String, unused

Returns the result:

  • Value , returns a value containing a JSON serializable