Module basic module

Module url

url processing module



Create UrlObject Request object, see UrlObject

UrlObject url.URL;

Static function


Parameter construction UrlObject Object

static String url.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

Return result:

  • String, Returns the successfully constructed string


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 that needs to be parsed
  • 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'}

Return result:

  • UrlObject, Returns an object containing parsed data


Combine relative paths into an absolute path

1 2
static String url.resolve(String _from, String to);

Call parameters:

  • _from: String, source path
  • to: String, relative path

Return result:

  • String, Return the absolute path