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

ZnUrl isAbsolute is dubious for file urls #71

Open
kasperosterbye opened this issue Jan 15, 2022 · 4 comments
Open

ZnUrl isAbsolute is dubious for file urls #71

kasperosterbye opened this issue Jan 15, 2022 · 4 comments

Comments

@kasperosterbye
Copy link

'file:///somepath' asZnUrl isAbsolute is false.

I would have expected it to be true.

The dubious part is the check for host in the implementation.

@svenvc
Copy link
Owner

svenvc commented Jan 16, 2022

Hi Kasper,

I agree that #isAbsolute and #isRelative are not crystal clear and hence maybe not that useful.

However, there is no such thing as a relative file:// reference, they are always absolute.

I don't know what you are trying to do, but if you want to combine an absolute path with a relative one, I suggest you look at #withRelativeReference: which implements a process defined in an RFC (there is also a big unit test).

Sven

@kasperosterbye
Copy link
Author

kasperosterbye commented Jan 16, 2022

I highly appreciate the #withRelativeReference: method - it is more than just a little useful.

The situation arose in a piece of code where I have a uri, which is either file, http, or some custom scheme type, or relative uris like 'doc/readme.md', and there was a test: myUri isAbsolute.
In my concrete scenario I believe I can check on the existing of a scheme.

Feel free to close this issue if you just think I misunderstood something :-)

@svenvc
Copy link
Owner

svenvc commented Jan 17, 2022

Let's keep it open for a while as a reminder that maybe we need to improve something here.

@kasperosterbye
Copy link
Author

One definition of isAbsolute could be based on rfc3986#appendix-A. My reading of the grammar is that absolute would be either if the URI-Reference has a scheme, or if the path starts with a /.

Now I am at it, I would have expected the last expression below to be true.

base:= 'http://a/b/c/d' asZnUrl. rel:= '../g'.
( base withRelativeReference: rel) = (base withRelativeReference: (rel asZnUrl asString))

But in the current implementation it is not (because of the implementation of ZnUrl>>parsePath: which removes '..' during parsing).

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