Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using / on AbsoluteUrl returns a Url #467

Open
bblfish opened this issue Sep 21, 2022 · 0 comments
Open

using / on AbsoluteUrl returns a Url #467

bblfish opened this issue Sep 21, 2022 · 0 comments
Assignees

Comments

@bblfish
Copy link

bblfish commented Sep 21, 2022

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
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants