scala-uri
scala-uri copied to clipboard
using `/` on AbsoluteUrl returns a Url
Describe the bug
Adding a path to an AbsoluteUrl
should return a new AbsoluteUrl
, not a Url
.
From the example below we see that the underlying objects are correct, but the type is not strict enough.
$ scala-cli repl --amm
Loading...
Welcome to the Ammonite Repl 2.5.4-15-f4a8969b (Scala 3.1.3 Java 19)
@ import $ivy.`io.lemonlabs::scala-uri:4.0.2`
import $ivy.$
@ import io.lemonlabs.uri.AbsoluteUrl
import io.lemonlabs.uri.AbsoluteUrl
@ import io.lemonlabs.uri.typesafe.dsl.*
import io.lemonlabs.uri.typesafe.dsl.*
@ val core = AbsoluteUrl.parse("http://www.w3.org/2001/sw/RDFCore")
core: AbsoluteUrl = AbsoluteUrl(
scheme = "http",
authority = Authority(userInfo = None, host = DomainName(value = "www.w3.org"), port = None),
path = AbsolutePath(parts = Vector("2001", "sw", "RDFCore")),
query = QueryString(params = Vector()),
fragment = None
)
@ core / "sub"
res18: Url = AbsoluteUrl(
scheme = "http",
authority = Authority(userInfo = None, host = DomainName(value = "www.w3.org"), port = None),
path = AbsolutePath(parts = Vector("2001", "sw", "RDFCore", "sub")),
query = QueryString(params = Vector()),
fragment = None
)
It works correctly with the removeEmptyPathParts
method.
@ core.removeEmptyPathParts()
res19: AbsoluteUrl = AbsoluteUrl(
scheme = "http",
authority = Authority(userInfo = None, host = DomainName(value = "www.w3.org"), port = None),
path = AbsolutePath(parts = Vector("2001", "sw", "RDFCore")),
query = QueryString(params = Vector()),
fragment = None
)