https://bz.apache.org/bugzilla/show_bug.cgi?id=69680

--- Comment #2 from Björn Kautler <bjo...@kautler.net> ---
If you would guard only with the first character being a separator, you would
still for example show

`jar:file:/opt/homebrew/Cellar/ant/1.10.15_1/libexec/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl`

as

`file:/opt/homebrew/Cellar/ant/1.10.15_1/libexec/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl`

which still is a bit off imho.

So if following that guard-tactic, I'd suggest to instead verify that the
protocol is `file` and then strip the first character of the file part away,
and in other cases return the full URL.

Actually you should probably also check the `host` field of the URL.
Because, if you get for example a remote file URL like for a UNC path, it will
be `new URI('file://wsl$/podman-machine-default/etc/fstab').toURL()` where
`file` then is `/podman-machine-default/etc/fstab` and it would display
`podman-machine-default/etc/fstab` which is also not too correct.

Actually, also on non-Windows systems generally the stripping is not a great
idea. If you have the URL `file:/etc/fstab`, you will get displayed
`etc/fstab`, which is a relative path, while it should really be the absolute
`/etc/fstab`.

My guess is, that someone on Windows implemented this, as there is probably the
only case where this stripping would improve the output for a local file, as
wihtout the stripping it would be `/c:/foo/bar` instead of the expected
`c:/foo/bar`.
Also the tests you have for the `Loading stylesheet` part for example
exclusively use Windows paths.

So I guess the most natural and clear way when not always showing the full URL,
would be to check:
- protocol is `file`
- host is `null` or empty
=> show only the path
- 3rd character of path is colon
=> strip the first character away
- in all other cases
=> show full URL

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to