parseURL

Attempts to parse an URL from a string and returns the specified component of the URL or $(D_PSYMBOL URL) if no component is specified.

  1. auto parseURL(char[] source)
    parseURL
    (
    string T
    )
    (
    const char[] source
    )
    if (
    T == "scheme" ||
    T == "host"
    ||
    T == "user"
    ||
    T == "pass"
    ||
    T == "path"
    ||
    T == "query"
    ||
    T == "fragment"
    ||
    T == "port"
    )
  2. URL parseURL(char[] source)

Parameters

T

"scheme", "host", "port", "user", "pass", "path", "query", "fragment".

source char[]

The string containing the URL.

Return Value

Type: auto

Requested URL component.

Examples

auto u = parseURL("http://example.org:5326");
assert(u.scheme == parseURL!"scheme"("http://example.org:5326"));
assert(u.host == parseURL!"host"("http://example.org:5326"));
assert(u.user == parseURL!"user"("http://example.org:5326"));
assert(u.pass == parseURL!"pass"("http://example.org:5326"));
assert(u.path == parseURL!"path"("http://example.org:5326"));
assert(u.query == parseURL!"query"("http://example.org:5326"));
assert(u.fragment == parseURL!"fragment"("http://example.org:5326"));
assert(u.port == parseURL!"port"("http://example.org:5326"));

Meta