Wren

Module url

URL and URLSearchParams (WHATWG URL Standard) as host objects. A URL's searchParams is linked to it both ways: changing the URL's search re-parses the list, changing the list rewrites the URL's query. Either may be released first.

Exposed to: Window, Worker. Source: api/url.widl.

Odin: import "wren:url".

Types

handle URL : Object

Checked by the browser on every call (lookup_URL).

handle URLSearchParams : Object

Checked by the browser on every call (lookup_URLSearchParams).

handle URLPattern : Object

Checked by the browser on every call (lookup_URLPattern).

enum URLComponent : i32

A component of a URL (also used by Location).

membervalue
Href0
Protocol1
Username2
Password3
Host4
Hostname5
Port6
Pathname7
Search8
Hash9
Origin10

enum URLPatternComponent : i32

A component of a URLPattern (the eight pattern components, in the spec's order).

membervalue
Protocol0
Username1
Password2
Hostname3
Port4
Pathname5
Search6
Hash7

Functions

URL_parse

URL URL_parse(string input, optional string base) raises

new URL(input, base): Type when the input (or the base) is not a valid URL or too long (web.url_max_length).

Odin: url.parse.

Raises: returns an Error (see web).

Host: URL_parse :: proc(c: ^Call, input: string, base: Maybe(string)) -> (u64, Api_Error)

URL_canParse

bool URL_canParse(string input, optional string base)

URL.canParse(input, base)

Odin: url.canParse.

Host: URL_canParse :: proc(c: ^Call, input: string, base: Maybe(string)) -> bool

URL_get

string URL_get(URL url, URLComponent component)

A getter: url.href, url.protocol...

Odin: url.get.

Host: URL_get :: proc(c: ^Call, url: Api_URL, component: Api_URLComponent) -> string

URL_set

void URL_set(URL url, URLComponent component, string value) raises

A setter. Only href can fail (Type); values the standard ignores leave the URL unchanged. Origin is read-only (Invalid_Argument).

Odin: url.set.

Raises: returns an Error (see web).

Host: URL_set :: proc(c: ^Call, url: Api_URL, component: Api_URLComponent, value: string) -> Api_Error

URL_searchParams

URLSearchParams URL_searchParams(URL url)

url.searchParams: the same object every time.

Odin: url.searchParams.

Host: URL_searchParams :: proc(c: ^Call, url: Api_URL) -> u64

URLSearchParams_create

URLSearchParams URLSearchParams_create(string init = "") raises

new URLSearchParams(init): a query string, with or without its "?". Type when too long.

Raises: returns an Error (see web).

Host: URLSearchParams_create :: proc(c: ^Call, init: string) -> (u64, Api_Error)

URLSearchParams_size

i32 URLSearchParams_size(URLSearchParams params)

params.size

Host: URLSearchParams_size :: proc(c: ^Call, params: Api_URLSearchParams) -> i32

URLSearchParams_append

void URLSearchParams_append(URLSearchParams params, usvstring name, usvstring value)

params.append(name, value)

Host: URLSearchParams_append :: proc(c: ^Call, params: Api_URLSearchParams, name: string, value: string)

URLSearchParams_delete

void URLSearchParams_delete(URLSearchParams params, string name, optional string value)

params.delete(name, value)

Host: URLSearchParams_delete :: proc(c: ^Call, params: Api_URLSearchParams, name: string, value: Maybe(string))

URLSearchParams_get

string URLSearchParams_get(URLSearchParams params, string name) raises

params.get(name): Not_Found when absent.

Raises: returns an Error (see web).

Host: URLSearchParams_get :: proc(c: ^Call, params: Api_URLSearchParams, name: string) -> (string, Api_Error)

URLSearchParams_count

i32 URLSearchParams_count(URLSearchParams params, string name)

params.getAll(name).length

Host: URLSearchParams_count :: proc(c: ^Call, params: Api_URLSearchParams, name: string) -> i32

URLSearchParams_getNth

string URLSearchParams_getNth(URLSearchParams params, string name, i32 index) raises

params.getAll(name)[index]: Not_Found past the end.

Raises: returns an Error (see web).

Host: URLSearchParams_getNth :: proc(c: ^Call, params: Api_URLSearchParams, name: string, index: i32) -> (string, Api_Error)

URLSearchParams_has

bool URLSearchParams_has(URLSearchParams params, string name, optional string value)

params.has(name, value)

Host: URLSearchParams_has :: proc(c: ^Call, params: Api_URLSearchParams, name: string, value: Maybe(string)) -> bool

URLSearchParams_set

void URLSearchParams_set(URLSearchParams params, usvstring name, usvstring value)

params.set(name, value)

Host: URLSearchParams_set :: proc(c: ^Call, params: Api_URLSearchParams, name: string, value: string)

URLSearchParams_sort

void URLSearchParams_sort(URLSearchParams params)

params.sort()

Host: URLSearchParams_sort :: proc(c: ^Call, params: Api_URLSearchParams)

URLSearchParams_toString

string URLSearchParams_toString(URLSearchParams params)

params.toString()

Host: URLSearchParams_toString :: proc(c: ^Call, params: Api_URLSearchParams) -> string

URLSearchParams_nameAt

string URLSearchParams_nameAt(URLSearchParams params, i32 index) raises

The name of the pair at index (iteration): Not_Found past the end.

Raises: returns an Error (see web).

Host: URLSearchParams_nameAt :: proc(c: ^Call, params: Api_URLSearchParams, index: i32) -> (string, Api_Error)

URLSearchParams_valueAt

string URLSearchParams_valueAt(URLSearchParams params, i32 index) raises

The value of the pair at index: Not_Found past the end.

Raises: returns an Error (see web).

Host: URLSearchParams_valueAt :: proc(c: ^Call, params: Api_URLSearchParams, index: i32) -> (string, Api_Error)

URLPattern_createString

URLPattern URLPattern_createString(string input, string base, bool has_base, bool ignore_case) raises

///////////////////////////// new URLPattern(patternString, baseURL?, {ignoreCase}): Type on a malformed pattern or missing protocol with no base. has_base and has_options distinguish an absent argument from an empty string / default.

Raises: returns an Error (see web).

Host: URLPattern_createString :: proc(c: ^Call, input: string, base: string, has_base: bool, ignore_case: bool) -> (u64, Api_Error)

URLPattern_createInit

URLPattern URLPattern_createInit(string protocol, bool has_protocol, string username, bool has_username, string password, bool has_password, string hostname, bool has_hostname, string port, bool has_port, string pathname, bool has_pathname, string search, bool has_search, string hash, bool has_hash, string base, bool has_base, bool ignore_case) raises

new URLPattern(init, {ignoreCase}): the eight optional component strings plus an optional baseURL. A component's has_* flag is false when the property was absent (defaults to the wildcard pattern).

Raises: returns an Error (see web).

Host: URLPattern_createInit :: proc(c: ^Call, protocol: string, has_protocol: bool, username: string, has_username: bool, password: string, has_password: bool, hostname: string, has_hostname: bool, port: string, has_port: bool, pathname: string, has_pathname: bool, search: string, has_search: bool, hash: string, has_hash: bool, base: string, has_base: bool, ignore_case: bool) -> (u64, Api_Error)

URLPattern_component

string URLPattern_component(URLPattern pattern, URLPatternComponent component)

A component's normalized pattern string (the getters protocol, username, ...).

Host: URLPattern_component :: proc(c: ^Call, pattern: Api_URLPattern, component: Api_URLPatternComponent) -> string

URLPattern_hasRegExpGroups

bool URLPattern_hasRegExpGroups(URLPattern pattern)

pattern.hasRegExpGroups

Host: URLPattern_hasRegExpGroups :: proc(c: ^Call, pattern: Api_URLPattern) -> bool

URLPattern_execString

i32 URLPattern_execString(URLPattern pattern, string input, string base, bool has_base)

Run exec()/test() against a URL string (resolved against base when has_base). Stores the result in the object. Returns 1 when it matched, 0 when it did not (exec returns null, test returns false).

Host: URLPattern_execString :: proc(c: ^Call, pattern: Api_URLPattern, input: string, base: string, has_base: bool) -> i32

URLPattern_execInit

i32 URLPattern_execInit(URLPattern pattern, string protocol, bool has_protocol, string username, bool has_username, string password, bool has_password, string hostname, bool has_hostname, string port, bool has_port, string pathname, bool has_pathname, string search, bool has_search, string hash, bool has_hash, string base, bool has_base)

Run exec()/test() against a per-component init and its baseURL. Returns 1/0 as execString.

Host: URLPattern_execInit :: proc(c: ^Call, pattern: Api_URLPattern, protocol: string, has_protocol: bool, username: string, has_username: bool, password: string, has_password: bool, hostname: string, has_hostname: bool, port: string, has_port: bool, pathname: string, has_pathname: bool, search: string, has_search: bool, hash: string, has_hash: bool, base: string, has_base: bool) -> i32

URLPattern_resultInputCount

i32 URLPattern_resultInputCount(URLPattern pattern)

After a successful exec: the number of inputs entries, and the i-th input string.

Host: URLPattern_resultInputCount :: proc(c: ^Call, pattern: Api_URLPattern) -> i32

URLPattern_resultInput

string URLPattern_resultInput(URLPattern pattern, i32 index) raises

Raises: returns an Error (see web).

Host: URLPattern_resultInput :: proc(c: ^Call, pattern: Api_URLPattern, index: i32) -> (string, Api_Error)

URLPattern_componentInput

string URLPattern_componentInput(URLPattern pattern, URLPatternComponent component)

The matched input value of a component (URLPatternComponentResult.input).

Host: URLPattern_componentInput :: proc(c: ^Call, pattern: Api_URLPattern, component: Api_URLPatternComponent) -> string

URLPattern_groupCount

i32 URLPattern_groupCount(URLPattern pattern, URLPatternComponent component)

The number of named groups of a component, and the i-th group's name.

Host: URLPattern_groupCount :: proc(c: ^Call, pattern: Api_URLPattern, component: Api_URLPatternComponent) -> i32

URLPattern_groupName

string URLPattern_groupName(URLPattern pattern, URLPatternComponent component, i32 index) raises

Raises: returns an Error (see web).

Host: URLPattern_groupName :: proc(c: ^Call, pattern: Api_URLPattern, component: Api_URLPatternComponent, index: i32) -> (string, Api_Error)

URLPattern_groupValue

string URLPattern_groupValue(URLPattern pattern, URLPatternComponent component, i32 index) raises

The i-th group's captured value: Not_Found when the group did not participate (its value is undefined).

Raises: returns an Error (see web).

Host: URLPattern_groupValue :: proc(c: ^Call, pattern: Api_URLPattern, component: Api_URLPatternComponent, index: i32) -> (string, Api_Error)

Edit this page on GitHub