URL

Holds the components of a URL. These are always stored as valid, URL-encoded values.

class val URL

Constructors

create

new val create()
: URL val^

Returns


build

new val build(
  from: String val,
  percent_encoded: Bool val = seq)
: URL val^ ?

Parameters

  • from: String val
  • percent_encoded: Bool val = seq

Returns


valid

new val valid(
  from: String val)
: URL val^ ?

Parameters

Returns


Public fields





  • var port: U16 val




Public Functions

is_valid

Return true if all elements are correctly URL encoded.

fun box is_valid()
: Bool val

Returns


string

Combine the components into a string.

fun box string()
: String iso^

Returns


join

Using this as a base URL, concatenate with another, possibly relative, URL in the same way a browser does for a link.

fun val join(
  that: URL val)
: URL val

Parameters

  • that: URL val

Returns


default_port

Report the default port for our scheme. Returns 0 for unrecognised schemes.

fun box default_port()
: U16 val

Returns


Private Functions

_parse

Parse the given string as a URL. Raises an error on invalid port number.

fun ref _parse(
  from: String val)
: None val ?

Parameters

Returns


_parse_scheme

Find the scheme, if any, at the start of the given string. The offset of the part following the scheme is returned.

fun box _parse_scheme(
  from: String val)
: (ISize val , String val)

Parameters

Returns


_parse_part

Attempt to parse the specified part out of the given string. Only attempt the parse if the given prefix is found first. Pass "" if no prefix is needed. The part ends when any one of the given terminator characters is found, or the end of the input is reached. The offset of the terminator is returned, if one is found.

fun box _parse_part(
  from: String val,
  prefix: String val,
  terminators: String val,
  offset: ISize val)
: (ISize val , String val)

Parameters

Returns


_split

Split the given string in 2 around the first instance of the specified separator. If the string does not contain the separator then the first resulting string is the whole src and the second is empty.

fun box _split(
  src: String val,
  separator: U8 val)
: (String val , String val)

Parameters

Returns


_parse_hostport

Split the given "host and port" string into the host and port parts.

fun box _parse_hostport(
  hostport: String val)
: (String val , String val)

Parameters

Returns