File tree Expand file tree Collapse file tree
main/java/org/biojava/nbio/core/util
test/java/org/biojava/nbio/core/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ public static String toUnixPath(String path) {
200200 public static String expandUserHome (String file ) {
201201 // replace any / with the proper separator (/ or \ for Linux and Windows respectively).
202202 file = file .replaceAll ("/" , "\\ " +File .separator ); //The "\\" is to escape the separator if needed.
203- if (file .startsWith ("~" + File .separator )) {
203+ if (file .startsWith ("~" ) && ( file . length () == 1 || File .separator . equals ( file . substring ( 1 , 2 )) )) {
204204 file = System .getProperty ("user.home" ) + file .substring (1 );
205205 }
206206 return file ;
Original file line number Diff line number Diff line change @@ -131,6 +131,11 @@ void unixPathReturnedUnchanged(){
131131 class ExpandUserHome {
132132 String currUserHome = System .getProperty ("user.home" );
133133 @ Test
134+ void minimalPath (){
135+ String path ="~" ;
136+ assertEquals (currUserHome , FileDownloadUtils .expandUserHome (path ));
137+ }
138+ @ Test
134139 void simplePath (){
135140 String path ="~/sequence.gb" ;
136141 assertEquals (currUserHome +File .separator +"sequence.gb" , FileDownloadUtils .expandUserHome (path ));
You can’t perform that action at this time.
0 commit comments