URLBuilder

class URLBuilder(var protocol: URLProtocol = URLProtocol.HTTP, var host: String = "", var port: Int = DEFAULT_PORT, user: String? = null, password: String? = null, pathSegments: List<String> = emptyList(), parameters: Parameters = Parameters.Empty, fragment: String = "", var trailingQuery: Boolean = false)

A URL builder with all mutable components

Constructors

Link copied to clipboard
fun URLBuilder(protocol: URLProtocol = URLProtocol.HTTP, host: String = "", port: Int = DEFAULT_PORT, user: String? = null, password: String? = null, pathSegments: List<String> = emptyList(), parameters: Parameters = Parameters.Empty, fragment: String = "", trailingQuery: Boolean = false)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun build(): Url

Build a Url instance (everything is copied to a new instance)

Link copied to clipboard

Build a URL string

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

URL fragment (anchor name)

Link copied to clipboard

name without port (domain)

Link copied to clipboard

URL query parameters

Link copied to clipboard

password part (optional)

Link copied to clipboard

URL path without query

Link copied to clipboard
var port: Int

port number

Link copied to clipboard

URL protocol (scheme)

Link copied to clipboard
var trailingQuery: Boolean = false

keep a trailing question character even if there are no query parameters

Link copied to clipboard
var user: String?

username part (optional)

Extensions

Link copied to clipboard
fun URLBuilder.appendPathSegments(segments: List<String>, encodeSlash: Boolean = false): URLBuilder

Adds segments to current encodedPath.

fun URLBuilder.appendPathSegments(vararg components: String, encodeSlash: Boolean = false): URLBuilder

Adds components to current encodedPath

Link copied to clipboard
Link copied to clipboard

Create a copy of this builder. Modifications in a copy is not reflected in the original instance and vise-versa.

Link copied to clipboard
Link copied to clipboard

Checks if Url has absolute path.

Link copied to clipboard

Checks if Url has absolute path.

Link copied to clipboard
fun URLBuilder.path(vararg path: String)

Replace components in the current encodedPath. The path components will be escaped, except / character.

Link copied to clipboard
Link copied to clipboard
fun URLBuilder.set(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, block: URLBuilder.() -> Unit = {})

Sets the url parts using the specified scheme, host, port and path. Pass null to keep existing value in the URLBuilder.

Link copied to clipboard

Take url parts from urlString throws URLParserException

Take components from another url builder

Take components from another url

Take URI components from uri

Take URL components from url