Skip to content

Commit ef33988

Browse files
authored
Merge pull request #168 from na-sa-do/expanduser-root
Correctly handle / in expanduser
2 parents 3366662 + 31b1ae7 commit ef33988

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/posix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
function Base.expanduser(fp::PosixPath)::PosixPath
2525
p = fp.segments
2626

27-
if p[1] == "~"
27+
if length(p) >= 1 && p[1] == "~"
2828
return length(p) > 1 ? joinpath(home(), p[2:end]...) : home()
2929
end
3030

test/system.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ ps = PathSet(; symlink=true)
360360
end
361361

362362
@testset "expanduser" begin
363+
@test expanduser(p"/") == p"/"
364+
363365
fp = joinpath(cwd(), "..", "src", "FilePathsBase.jl")
364366
@test string(expanduser(fp)) == expanduser(string(fp))
365367

0 commit comments

Comments
 (0)