class URL

Supported only in the v8 engine. Introduced in Max v9.2.0.

Parses and manipulates URLs.

Supported schemes are http, https, ws, and wss. There is no ambient location global in this runtime, so fetch(), Request, and WebSocket require absolute URLs; use a URL with an explicit base for relative resolution.

Example

const u = new URL("/path?x=1", "https://example.com");
post(u.href, "\n"); // https://example.com/path?x=1
post(u.searchParams.get("x"), "\n"); // 1

Index

Constructors

Properties

Methods

new URL(input, base)

new URL(input: string, base?: string | URL);

Constructs a new instance of the URL class

ParameterTypeDescription
inputstringan absolute URL string, or a relative URL when base is supplied.
optional basestring | URLan optional base URL string or URL for relative resolution.

hash string

The fragment including the leading #.

host string

The host, including port when present.

hostname string

The host without the port.

href string

The full serialized URL.

origin string read-only

The origin (read-only), e.g. "https://example.com".

pathname string

The path portion of the URL.

port string

The port as a string, or "" when none.

protocol string

The protocol including the trailing colon, e.g. "https:".

The query string including the leading ?, kept in sync with URL.searchParams.

searchParams URLSearchParams read-only

The parsed query parameters, kept in sync with URL.search.

toString()

Returns the serialized URL (same as URL.href).

toString(): string;
NameTypeDescription
Return Valuestring