Url

Url is a value type that represents either a local or network URL.

property Url local: "images/interface/background.png"
property Url network: "http://www.zingstudio.io/demos/random.jpg"

The general form a URL takes is:

scheme :// domain /path ? query # fragment

function Url(String path) → Url

Creates a new Url from the specified path. If path is relative, by default it will be resolved relative to the calling file.

If path is an empty string, an empty Url will be created.

The following optional arguments can be used to adjust the way the path is resolved as shown below.

function myImage(String name) -> Url {
    // If name is empty, an empty Url will still be returned
    return Url(name, relativeTo: "images", extension: "png")
}

optional Url relativeTo

If provided, the relativeTo argument is used to resolve relative paths instead of the calling file path.

optional String extension

If provided, the extension is also appended to path.

property String schemeread only

property String domainread only

property String pathread only

property String queryread only

property String fragmentread only

The scheme, domain, path, query and fragment components of the URL.

static function Url.percentEncoded(String string) → String

static function Url.percentDecoded(String string) → String

Returns a percent-encoded or decoded (also known as URL encoding) version of string.

Percent-encoding is used to encode information in a uniform resource identifier, and replaces all non-alphanumeric characters, except '-', '_', '.' and '~', with a percent sign followed by two hex digits. If string contains UTF-16 characters, it is converted to UTF-8 before encoding.