URL
Parse and build URLs and query strings.
Always available
No import needed. These names are in scope in every file.
URLSearchParams class
ts
class URLSearchParamsType only: the runtime hands you instances; you never construct it yourself.
Mutable, ordered query-string parameter list. Obtained from URL.searchParams; mutating it rewrites the parent URL's search component on the next read. Preserves insertion order and allows repeated keys (use append to add duplicates, set to collapse them).
URLSearchParams.append
ts
append(name: string, value: string): voidAppend a name/value pair, even if name already exists.
URLSearchParams.delete
ts
delete(name: string): voidRemove every entry whose name equals name.
URLSearchParams.entries
ts
entries(): Array<Array<string>>Return all entries as an array of [name, value] pairs in insertion order.
URLSearchParams.get
ts
get(name: string): string | nullReturn the first value associated with name, or null if name is not present.
URLSearchParams.has
ts
has(name: string): booleanTrue when at least one entry has the given name.
URLSearchParams.keys
ts
keys(): Array<string>Return every entry name in insertion order.
URLSearchParams.set
ts
set(name: string, value: string): voidReplace every existing entry for name with a single entry (name, value). The first occurrence is updated in place; subsequent duplicates are dropped. Appends a fresh entry if name is not present.
URLSearchParams.toString
ts
toString(): stringRender as a percent-encoded query string (without the leading ?). Returns the empty string when no entries are present.
URLSearchParams.values
ts
values(): Array<string>Return every entry value in insertion order.
URL class
ts
class URLParsed URL with mutable components. Constructing throws TypeError if input cannot be parsed. Writes to individual components rebuild the dependent fields (e.g. assigning to protocol updates href and origin). The searchParams accessor returns a live URLSearchParams bound to this URL's query string.
URL.hash
ts
hash: stringFragment including the leading #, or empty when absent.
URL.host
ts
host: stringhostname plus :port when a non-default port is present.
URL.hostname
ts
hostname: stringHost without port.
URL.href
ts
href: stringFull URL, regenerated from the component fields.
URL.origin
ts
origin: stringprotocol + // + host for hierarchical URLs. Read-only in spirit: assigning has no defined effect.
URL.pathname
ts
pathname: stringPath component including the leading /.
URL.port
ts
port: stringPort as a string. Empty when the protocol's default port applies.
URL.protocol
ts
protocol: stringScheme including the trailing : (e.g. "https:").
URL.search
ts
search: stringQuery string including the leading ?, or empty when absent.
URL.searchParams
ts
searchParams: URLSearchParamsLive view of the query string as a URLSearchParams. Mutations propagate back into search and href.
new URL()
ts
constructor(input: string)Parse input as a URL. Throws TypeError if parsing fails or input is not a string.
URL.toString
ts
toString(): stringEquivalent to reading href.
URL.decode
ts
static decode(value: string): stringPercent-decode a single value (the inverse of encode).
URL.encode
ts
static encode(value: string): stringPercent-encode a single value for use in a URL component.
Generated from lang/types/builtin_url.d.tks in the ThicketScript repository.