Skip to content
FutureBlitz

    Install

    Import std.net.url

    Url

    std.net.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")

    std/net/url.fb, line 38

    • 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.

    Report an issue with this page or with FutureBlitz on GitHub.