create

abstract fun create(url: URL): URL

Constructor: From URL

Construct a copy of the provided URL object. Since the URL is already parsed, we can easily copy it without validating, as it was validated when it was first constructed.

Relative URLs are not allowed via this constructor.

Return

Copied URL object.

Parameters

url

URL to create a copy of.

See also

to create a URL from a string.


abstract fun create(url: String): URL

Constructor: From String

Construct a new URL object from the provided string. If the provided string is not a valid URL, an error is thrown. The resulting URL can be considered validated and well-formed.

Return

Parsed URL object.

Parameters

url

String to create a structured/parsed URL from.

See also

To create a URL from another URL.

Throws

If the provided string is not a valid URL.


abstract fun create(url: String, base: String): URL

Constructor: From String, with Base URL as String

Construct a new URL object from the provided string. If the provided string is not a valid URL, an error is thrown. The resulting URL can be considered validated and well-formed.

If url is relative, base is parsed first and used to resolve the effective absolute URL.

Return

Parsed URL object.

Parameters

url

String to create a structured/parsed URL from.

base

Base URL to use if url is relative.

See also

To create a URL from another URL.

Throws

If the provided string is not a valid URL.