Stef,

Yes, this is confusing.

The first 2 forward slashed are part of the scheme, file:// or http://

Next comes the host:port, but that does not make too much sense for a File URL.

Finally comes the path.

For the syntax to make sense, you need a third / (to indicate that there is no 
host:port).

If you inspect the ZnUrl object in your second example, 'file://toto.png' 
asUrl, you will see that is has toto.png as host, not as path. This is in fact 
an invalid File URL.

The annoying thing is, there is no such thing as a relative File URL.

https://en.wikipedia.org/wiki/File_URI_scheme

Now, for your problem, I would not allow the use of file:// there, and just 
simpler file references (using #asFileReference), which can be relative.

Sven

PS: Also, the methods #isAbsolute and #isRelative do not make much sense on 
ZnUrl, see the method comment/implementation.

> On 31 Aug 2021, at 14:54, stephane ducasse <stephane.duca...@inria.fr> wrote:
> 
> Hi 
> 
> I’m a bit confused. When I use isAbsolute I get 
> 
> 'file:///toto.png' asUrl isAbsolute 
> >>> false
> 
> 
> 'file://toto.png' asUrl isAbsolute 
> >>> true
> 
> 
> Now I confused because as Unix / is absolute so file://toto.png would be 
> relative.
> and /foo is absolute. 
> 
> Are URLs so different than files?
> Are the results I get correct?
> 
> I ask this question in the context of Microdown if people write 
> 
> ![caption](file://toto.png).
> ![caption](figures/toto.png)
> ![caption](file:///toto.png).
> 
> S
> 
> 

Reply via email to