Import std.net.url
Url
struct
Public Struct Url Implements Hashable, Printable
A URL. Parse reads one, and ToString gives its text, which reads back as the same URL.
Examples
Local url = Url.Parse("https://ada@example.com:8443/docs/../guide?lang=en#intro")
Expect(url != Null)
If url == Null Then Return
Expect(url.Host == "example.com" && url.Port == 8443)
Expect(url.Path == "/guide" && url.Fragment == "intro")
Expect(url.Params.Get("lang") == "en")
Expect(url.Origin == "https://example.com:8443")
Local logo = url.Resolve("/images/logo.png")
Expect(logo?.ToString() == "https://ada@example.com:8443/images/logo.png")-
Its scheme, in lowercase, like "https".
-
Who it's for, percent-encoded, or "".
-
Its password, percent-encoded, or "".
-
Its host as its text has it, without the port: a domain in lowercase ASCII, an IPv4 address, an IPv6 one in brackets, or an opaque host; "" for an empty one, as file:/// has, and Null for none, as mailto:a@b.com has.
-
Its port, or Null for none, or the scheme's own, like 443 for https.
-
Its query, after its ?, and its fragment, after its #, or Null for none.
-
Its fragment, after its #, or Null for none.
-
The URL
textwrites, or Null when it isn't one. Space and controls around it, and tabs and line breaks in it, are left out. -
The URL
textwrites, relative tobase: a whole URL, or a path, query, or fragment to resolve againstbase, as a link in a page is. -
The URL
textwrites, relative to the URLbasewrites, or Null when either isn't one. -
What
textresolves to, relative to this URL. -
Its path as its text has it: each segment after a /, or its opaque path.
-
Whether its path is opaque, as mailto:a@b.com's and data:text/plain,hi's are, so it's no base for a relative path.
-
Its port, or its scheme's own when it has none, or Null for a scheme without one.
-
Its query's names and values, a new QueryParams each time. A ? the query starts with is part of its first name.
-
Where it's from, as a browser compares sites: its scheme, host, and port, like "https://example.com:8080", for http, https, ws, wss, and ftp, the origin of the URL a blob: URL's path is, and "null" for the rest.
-
Its text, as the WHATWG URL serializer writes it.
-
textwith what isn't a letter, a digit, or one of !'()*-._~ percent-encoded as its UTF-8 bytes, as a query's name or value, or a path's segment, takes any text. -
textwith each % and two hex digits as the byte they stand for, read as UTF-8 as the Encoding Standard's decoder reads it: one U+FFFD for each byte that can't start a code point, and one for each start of one that's cut short, before the byte that cuts it.
Report an issue with this page or with FutureBlitz on GitHub.