File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -585,11 +585,23 @@ defmodule Path do
585585
586586 defp expand_home ( type ) do
587587 case IO . chardata_to_string ( type ) do
588- "~" <> rest -> System . user_home! <> rest
588+ "~" <> rest -> resolve_home ( rest )
589589 rest -> rest
590590 end
591591 end
592592
593+ defp resolve_home ( "" ) , do: System . user_home!
594+
595+ defp resolve_home ( rest ) do
596+ case { rest , major_os_type } do
597+ { "\\ " <> _ , :win32 } ->
598+ System . user_home! <> rest
599+ { "/" <> _ , _ } ->
600+ System . user_home! <> rest
601+ _ -> rest
602+ end
603+ end
604+
593605 defp normalize ( path ) , do: normalize ( split ( path ) , [ ] )
594606
595607 defp normalize ( [ ".." | t ] , [ "/" | _ ] = acc ) do
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ defmodule PathTest do
112112 assert Path . expand ( "~/file" , "whatever" ) == Path . join ( home , "file" )
113113 assert Path . expand ( "file" , Path . expand ( "~" ) ) == Path . expand ( "~/file" )
114114 assert Path . expand ( "file" , "~" ) == Path . join ( home , "file" )
115+ assert Path . expand ( "~file" ) == Path . join ( System . cwd! , "file" )
115116 end
116117
117118 test :expand_path do
You can’t perform that action at this time.
0 commit comments