Module basic module

Module url

url processing module

Object

URL

Create 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, 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

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

resolve

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