url

Types from the Go package url (a library PocketBase builds on), as JavaScript sees them: they turn up as values of PocketBase's types and of hook events.

url.URL

A URL represents a parsed URL (technically, a URI reference).

The general form represented is:

	[scheme:][//[userinfo@]host][/]path[?query][#fragment]

URLs that do not start with a slash after the scheme are interpreted as:

	scheme:opaque[?query][#fragment]

The Host field contains the host and port subcomponents of the URL. When the port is present, it is separated from the host with a colon. When the host is an IPv6 address, it must be enclosed in square brackets: "[fe80::1]:80". The net.joinHostPort function combines a host and port into a string suitable for the Host field, adding square brackets to the host when necessary.

Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/. A consequence is that it is impossible to tell which slashes in the Path were slashes in the raw URL and which were %2f. This distinction is rarely important, but when it is, the code should use the URL.escapedPath method, which preserves the original encoding of Path. The Fragment field is also stored in decoded form, use URL.escapedFragment to retrieve the original encoding.

The URL.string method uses the URL.escapedPath method to obtain the path.

Member Type
scheme string
opaque string // encoded opaque data
user? Userinfo // username and password information
host string // "host" or "host:port" (see Hostname and Port methods)
path string // path (relative paths may omit leading slash)
fragment string // fragment for references (without '#')
rawQuery string RawQuery contains the encoded query values, without the initial '?'. Use URL.Query to decode the query.
rawPath string RawPath is an optional field containing an encoded path hint. See the EscapedPath method for more details.
rawFragment string RawFragment is an optional field containing an encoded fragment hint. See the EscapedFragment method for more details.
forceQuery boolean ForceQuery indicates whether the original URL contained a query ('?') character. When set, the String method will include a trailing '?', even when RawQuery is empty.
omitHost boolean OmitHost indicates the URL has an empty host (authority). When set, the String method will not include the host when it is empty.
escapedPath() (): string EscapedPath returns the escaped form of u.Path. In general there are multiple possible escaped forms of any path. EscapedPath returns u.RawPath when it is a valid escaping of u.Path. Otherwise EscapedPath ignores u.RawPath and computes an escaped form on its own. The URL.string and URL.requestURI methods use EscapedPath to construct their results. In general, code should call EscapedPath instead of reading u.RawPath directly.
escapedFragment() (): string EscapedFragment returns the escaped form of u.Fragment. In general there are multiple possible escaped forms of any fragment. EscapedFragment returns u.RawFragment when it is a valid escaping of u.Fragment. Otherwise EscapedFragment ignores u.RawFragment and computes an escaped form on its own. The URL.string method uses EscapedFragment to construct its result. In general, code should call EscapedFragment instead of reading u.RawFragment directly.
string() (): string String reassembles the URL into a valid URL string. The general form of the result is one of:
redacted() (): string Redacted is like URL.string but replaces any password with "xxxxx". Only the password in u.User is redacted.
isAbs() (): boolean IsAbs reports whether the URL is absolute. Absolute means that it has a non-empty scheme.
parse() (ref: string): (URL) Parse parses a URL in the context of the receiver. The provided URL may be relative or absolute. Parse returns nil, err on parse failure, otherwise its return value is the same as URL.resolveReference.
resolveReference() (ref: URL): (URL) ResolveReference resolves a URI reference to an absolute URI from an absolute base URI u, per RFC 3986 Section 5.2. The URI reference may be relative or absolute. ResolveReference always returns a new URL instance, even if the returned URL is identical to either the base or reference. If ref is an absolute URL, then ResolveReference ignores base and returns a copy of ref.
query() (): Values Query parses RawQuery and returns the corresponding values. It silently discards malformed value pairs. To check errors use ParseQuery.
requestURI() (): string RequestURI returns the encoded path?query or opaque?query string that would be used in an HTTP request for u.
hostname() (): string Hostname returns u.Host, stripping any valid port number if present.
port() (): string Port returns the port part of u.Host, without the leading colon.
marshalBinary() (): string|Array<number>
appendBinary() (b: string|Array<number>): string|Array<number>
unmarshalBinary() (text: string|Array<number>): void
joinPath() (...elem: string[]): (URL) JoinPath returns a new URL with the provided path elements joined to any existing path and the resulting path cleaned of any ./ or ../ elements. Any sequences of multiple / characters will be reduced to a single /. Path elements must already be in escaped form, as produced by PathEscape.
clone() (): (URL) Clone creates a deep copy of the fields of the subject URL.

url.Values

Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.

Has everything { [key: string]: any } has.

Member Type
get() (key: string): string Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.
set() (key: string, value: string): void Set sets the key to value. It replaces any existing values.
add() (key: string, value: string): void Add adds the value to key. It appends to any existing values associated with key.
del() (key: string): void Del deletes the values associated with key.
has() (key: string): boolean Has checks whether a given key is set.
clone() (): Values Clone creates a deep copy of the subject Values.
encode() (): string Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.

url.Userinfo

The Userinfo type is an immutable encapsulation of username and password details for a URL. An existing Userinfo value is guaranteed to have a username set (potentially empty, as allowed by RFC 2396), and optionally a password.

Member Type
username() (): string Username returns the username.
password() (): [string, boolean] Password returns the password in case it is set, and whether it is set.
string() (): string String returns the encoded userinfo information in the standard form of "username[:password]".