Attempts to parse an URL from a string. Output string data (scheme, user, etc.) are just slices of input string (i.e., no memory allocation and copying).
The anchor.
The hostname.
The password.
The path.
The port number.
The query string.
The URL scheme.
The username.
auto u = URL("example.org"); assert(u.path == "example.org"); u = URL("relative/path"); assert(u.path == "relative/path"); // Host and scheme u = URL("https://example.org"); assert(u.scheme == "https"); assert(u.host == "example.org"); assert(u.path is null); assert(u.port == 0); assert(u.fragment is null); // With user and port and path u = URL("https://hilary:putnam@example.org:443/foo/bar"); assert(u.scheme == "https"); assert(u.host == "example.org"); assert(u.path == "/foo/bar"); assert(u.port == 443); assert(u.user == "hilary"); assert(u.pass == "putnam"); assert(u.fragment is null); // With query string u = URL("https://example.org/?login=true"); assert(u.scheme == "https"); assert(u.host == "example.org"); assert(u.path == "/"); assert(u.query == "login=true"); assert(u.fragment is null); // With query string and fragment u = URL("https://example.org/?login=false#label"); assert(u.scheme == "https"); assert(u.host == "example.org"); assert(u.path == "/"); assert(u.query == "login=false"); assert(u.fragment == "label"); u = URL("redis://root:password@localhost:2201/path?query=value#fragment"); assert(u.scheme == "redis"); assert(u.user == "root"); assert(u.pass == "password"); assert(u.host == "localhost"); assert(u.port == 2201); assert(u.path == "/path"); assert(u.query == "query=value"); assert(u.fragment == "fragment");
A Unique Resource Locator.