Skip to content

URL

[Source]

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

class val URL

Constructors

create

[Source]

Create an empty URL.

new val create()
: URL val^

Returns


build

[Source]

Parse the URL string into its components. If it isn't URL encoded, encode it. If existing URL encoding is invalid, raise an error.

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

Parameters

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

Returns


valid

[Source]

Parse the URL string into its components. If it isn't URL encoded, raise an error.

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

Parameters

Returns


Public fields

var scheme: String val

[Source]

URL scheme.

If the given URL does not provide a scheme, this will be the empty string.

See also RFC 3986.


var user: String val

[Source]

URL user as part of the URLs authority component:

authority = [ user [ ":" password ] "@" ] host [ ":" port ]

If the URL does not provide user information, this will be the empty string.

See also RFC 3986.


var password: String val

[Source]

URL password as part of the URLs authority component:

authority = [ user [ ":" password ] "@" ] host [ ":" port ]

If the URL does not provide a password, this will be the empty string.

See also RFC 3986.


var host: String val

[Source]

URL host as part of the URLs authority component:

authority = [ user [ ":" password ] "@" ] host [ ":" port ]

If the URL does not provide a host, this will be the empty string.

See also RFC 3986.


var port: U16 val

[Source]

URL port as part of the URLs authority component:

authority = [ user [ ":" password ] "@" ] host [ ":" port ]

If the URL does not provide a port, this will be the empty string.

See also RFC 3986.


var path: String val

[Source]

URL path component.

If the URL does not provide a path component, this will be the empty string.

See also RFC 3986.


var query: String val

[Source]

URL query component.

If the URL does not provide a query component, this will be the empty string.

See also RFC 3986.


var fragment: String val

[Source]

Url fragment identifier component.

If the URL does not provide a fragment identifier component, this will be the empty string.

See also RFC 3986.


Public Functions

is_valid

[Source]

Return true if all elements are correctly URL encoded.

fun box is_valid()
: Bool val

Returns


string

[Source]

Combine the components into a string.

fun box string()
: String iso^

Returns


join

[Source]

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

[Source]

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

fun box default_port()
: U16 val

Returns