Skip to content

Commit

Permalink
Construct proper URIs for paths when run on WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Jan 15, 2025
1 parent 30177d0 commit aeadfd1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,14 @@
end

@testset "uripath" begin
host = if Sys.iswindows() "" else gethostname() end
host = if Sys.iswindows()
""
elseif ispath("/proc/sys/fs/binfmt_misc/WSLInterop")
distro = get(ENV, "WSL_DISTRO_NAME", "") # See <https://patrickwu.space/wslconf/>
"wsl%24/$distro" # See <https://github.com/microsoft/terminal/pull/14993> and <https://learn.microsoft.com/en-us/windows/wsl/filesystems>
else
gethostname()
end
sysdrive, uridrive = if Sys.iswindows() "C:\\", "C:/" else "/", "" end
@test Base.Filesystem.uripath("$(sysdrive)some$(sep)file.txt") == "file://$host/$(uridrive)some/file.txt"
@test Base.Filesystem.uripath("$(sysdrive)another$(sep)$(sep)folder$(sep)file.md") == "file://$host/$(uridrive)another/folder/file.md"
Expand Down

0 comments on commit aeadfd1

Please sign in to comment.