Seeker14491 / opener

Open a file or link in the system default program.
Apache License 2.0
54 stars 11 forks source link

URL opened as file path in WSL2 #20

Closed btwiuse closed 1 year ago

btwiuse commented 1 year ago

I use open_browser to open the http://127.0.0.1:33541 in WSL2 with BROWSER="/mnt/c/Program Files/Firefox Nightly/firefox.exe"

The browser opens file://///wsl.localhost/Arch/home/aaron/gear/http/127.0.0.133541 instead of http://127.0.0.1:33541.

Such behavior is caused by wslpath:

$ wslpath -w '127.0.0.1:33541'
http\127.0.0.133541

Can we check if the opened path is a url first before passing it to wslpath?

Seeker14491 commented 1 year ago

I just fixed this 3 days ago (474f93b75ca3ea6a3c50fe7c9dbe293fd0a18d40). I plan on releasing a new version very soon.

btwiuse commented 1 year ago

But the current solution is relying on the presence of wslview, which is unavailable on non-ubuntu distros. (I use arch btw)

Seeker14491 commented 1 year ago

It's available for installation on other distros including Arch (which is also my WSL distro), but it's not preinstalled. I did just find out it's no longer preinstalled on Ubuntu as of 22.04. If wslview is missing, there is fallback to xdg-open, though that might not do the "right" thing.

Seeker14491 commented 1 year ago

I just released v0.6.0 which includes the fix. I opened #21 for the issue of requiring either wslview or xdg-open to be available on WSL.