Skip to content
FutureBlitz

    Install

    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.

    std/net/url.fb, line 22

    • Public ReadOnly Field Scheme: String field #

      Its scheme, in lowercase, like "https".

    • Public ReadOnly Field Username: String field #

      Who it's for, percent-encoded, or "".

    • Public ReadOnly Field Password: String field #

      Its password, percent-encoded, or "".

    • Public ReadOnly Field Host: String? field #

      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.

    • Public ReadOnly Field Port: Int? field #

      Its port, or Null for none, or the scheme's own, like 443 for https.

    • Public ReadOnly Field Query: String? field #

      Its query, after its ?, and its fragment, after its #, or Null for none.

    • Public ReadOnly Field Fragment: String? field #

      Its fragment, after its #, or Null for none.

    • Public Static Method Parse(text: String): Url? static method #

      The URL text writes, or Null when it isn't one. Space and controls around it, and tabs and line breaks in it, are left out.

    • Public Static Method Parse(text: String, base: Url): Url? static method #

      The URL text writes, relative to base: a whole URL, or a path, query, or fragment to resolve against base, as a link in a page is.

    • Public Static Method Parse(text: String, base: String): Url? static method #

      The URL text writes, relative to the URL base writes, or Null when either isn't one.

    • Public Method Resolve(text: String): Url? method #

      What text resolves to, relative to this URL.

    • Public Property Path: String property #

      Its path as its text has it: each segment after a /, or its opaque path.

    • Public Property HasOpaquePath: Bool property #

      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.

    • Public Property PortOrDefault: Int? property #

      Its port, or its scheme's own when it has none, or Null for a scheme without one.

    • Public Property Params: QueryParams property #

      Its query's names and values, a new QueryParams each time. A ? the query starts with is part of its first name.

    • Public Property Origin: String property #

      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.

    • Public Method ToString(): String method #

      Its text, as the WHATWG URL serializer writes it.

    • Public Static Method Encode(text: String): String static method #

      text with 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.

    • Public Static Method Decode(text: String): String static method #

      text with 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.

    std/net/url.fb, line 181

    • Public New() constructor #

      A new, empty QueryParams.

    • Public New(query: String) constructor #

      The names and values query has, after its ?, if it starts with one.

    • Public Property Count: Int property #

      How many pairs it has.

    • Public Method Get(name: String): String? method #

      The first value of name, or Null when it has none.

    • Public Method GetAll(name: String): String[] method #

      Each value of name, in order.

    • Public Method Contains(name: String): Bool method #

      Whether it has name, or name with value.

    • Public Method Contains(name: String, value: String): Bool method #

      Whether it has name with value.

    • Public Method Add(name: String, value: String) method #

      Adds name and value at the end, after any values name has.

    • Public Method Set(name: String, value: String) method #

      Gives name value: its first pair's, taking the others out, or a new one at the end.

    • Public Method Remove(name: String): Bool method #

      Takes out each pair of name, or of name and value, and gives whether there was one.

    • Public Method Remove(name: String, value: String): Bool method #

      Takes out each of name's values that are value, and tells whether it had any.

    • Public Method Sort() method #

      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.

    • Public Method Iterate(): ArrayIterator<(String, String)> method #

      Each name and value, in order.

    • Public Method ToString(): String method #

      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.