Module Basic module

Module url

url processing module

Object

URL

Create a UrlObject request object, see UrlObject

1
UrlObject url.URL;

Static function

format

Parameter construction UrlObject object

1
static String url.format(Object args);

Call parameters:

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

Return result:

  • String , returns a successfully constructed string

parse

Parse a url string

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

Call parameters:

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

Return result:

  • UrlObject , returns an object containing parsed data