Function parseURL
Attempts to parse an URL from a string and returns the specified component of the URL or URL if no component is specified.
auto parseURL(string T)
(
const char[] source
)
if (T == "scheme" || T == "host" || T == "user" || T == "pass" || T == "path" || T == "query" || T == "fragment" || T == "port");
URL parseURL
(
const(char[]) source
) pure @nogc;
Parameters
Name | Description |
---|---|
T | "scheme", "host", "port", "user", "pass", "path", "query", "fragment". |
source | The string containing the URL. |
Returns
Requested URL component.
Example
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"));