A Kotlin port of the URL value object library https://github.com/krixon/url
- Java 1.8
implementation("uk.co.ben_gibson:url:0.0.7")
<dependency>
<groupId>uk.co.ben_gibson</groupId>
<artifactId>url</artifactId>
<version>0.0.7</version>
</dependency>
URL.fromString("https://example.com:8080/foo/bar?limit=10#L1-L10")
// OR
URL(
scheme = Scheme.https(),
host = Host("example.com"),
port = Port(8080),
path = Path("foo/bar/baz"),
queryString = QueryString.fromMap(mapOf("order" to listOf("id", "name"))),
fragment = Fragment("L10")
)
val path = Path("foo/bar/")
.with("/baz/slug/")
.withSegment("my slug")
.withSegments("that", "is", "awesome")
path.toString() // -> foo/bar/baz/slug/my%20slug/that/is/awesome
$ ./gradlew build
$ ./gradlew test