URL
classin packageklyn.net
public class URL extends Object:
└ URL
Parsed URL value inspired by Java's `URL`. Supported schemes for `toHttpRequest()` are `http` and `https`.
import klyn.net

url = URL("https://example.com:8443/api?q=1#frag")
print(url.protocol)
print(url.host)
print(url.effectivePort)
Fields
Modifier and Type Member Description
public toHttpRequest(method
toHttpRequest(method as String = "GET",
Builds an HTTP request targeting this URL.
Properties
Modifier and Type Member Description
public readonly property authority
authority as String:
Authority component as written in the URL.
public readonly property defaultPort
defaultPort as Int:
Returns the default port for the current scheme.
public readonly property effectivePort
effectivePort as Int:
Returns the explicit port or the scheme default port.
public readonly property file
file as String:
Returns the file component (`path` plus optional query string).
public readonly property fragment
fragment as String:
Fragment component without `#`.
public readonly property host
host as String:
Host or bracketed IPv6 literal.
public readonly property isHttps
isHttps as Boolean:
Returns true for `https` URLs.
public readonly property path
path as String:
Path component, defaulting to `/`.
public readonly property port
port as Int:
Explicit port or `-1` when omitted.
public readonly property protocol
protocol as String:
Lower-case URL scheme.
public readonly property query
query as String:
Query component without `?`.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public URL Parses a URL string.
Methods
Modifier and Type Member Description
public static fromObject
fromObject(value as Object) as URL throws MalformedURLException:
Converts an object to `URL`.
public toExternalForm
toExternalForm() as String:
Alias of `toString()`.
public override toString
toString() as String:
No summary.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml