Import std.net.url
std.net.url
std.net's Url and QueryParams, as the WHATWG URL Standard has them: a URL read from its text, against a base or not, its parts and its origin, and the text it writes back, with what isn't in a part's set of code points percent-encoded; and a query's name and value pairs, as an HTML form sends them. A host that isn't ASCII becomes its Punycode; UTS #46's mapping of one, which the standard's domain to ASCII has, waits for std.text.unicode, so until then a host's ASCII letters map to lowercase, fullwidth ASCII to ASCII, and the ideographic full stops to a dot; its spaces map to a space, which no host has; soft hyphens and zero widths are left out; U+FFFD, C1 controls, and noncharacters fail it; and its other code points stay as they are.
std/net/url.fb
Types
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.
-
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.
QueryParams
class
Public Class QueryParams Implements Printable, Iterable<(String, String)>
A query's names and values, in order, as an HTML form sends them: "a=1&b=two%20words", where a + is a space. One name can have many values.
-
A new, empty QueryParams.
-
The names and values
queryhas, after its ?, if it starts with one. -
How many pairs it has.
-
The first value of
name, or Null when it has none. -
Each value of
name, in order. -
Whether it has
name, ornamewith value. -
Whether it has
namewithvalue. -
Adds
nameandvalueat the end, after any valuesnamehas. -
Gives
namevalue: its first pair's, taking the others out, or a new one at the end. -
Takes out each pair of
name, or ofnameand value, and gives whether there was one. -
Takes out each of
name's values that arevalue, and tells whether it had any. -
Puts the pairs in the order of their names, by UTF-16 code units, as the standard says, keeping the order of one name's values: a merge sort, by each name's order worked out once.
-
Each name and value, in order.
-
The query's text, without a ?: each name, =, and value, with & between pairs, a space as a +, and what isn't a letter, a digit, or one of *-._ percent-encoded.
Report an issue with this page or with FutureBlitz on GitHub.