xdg-open doesn't handle hostnames in `file:` URIs
xdg-open fails to open URIs like file://hostname/foo/bar
unless hostname
is localhost
. It should at least handle the current hostname.
This is relevant because programs like systemd or GNU ls have recently started emitting hyperlinks on file names for capable terminal emulators, and the links are often of the form above. This caused at least one issue in the wild: https://github.com/kovidgoyal/kitty/issues/2970.
I am not sure what the best option is for getting the hostname, which is why I'm not directly submitting a PR. I think a reasonable approach would be to try the non-standard hostname
command if it exists, and, if not, fall back to uname -n
which POSIX defines as "the name of this node within an implementation-defined communications network" (which on Linux just means hostname).