File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -73,21 +73,25 @@ public static function joinPath($path1, $path2) {
73
73
$ path2 = trim ($ path2 , $ win_delim );
74
74
}
75
75
76
- //preserve the root (Linux, Mac)
77
- $ startChar = substr ($ path1Orig , 0 , 1 );
78
- if ($ startChar == $ root_delim ) {
79
- $ path1 = $ root_delim . $ path1 ;
80
- }
81
76
77
+ $ finalPath ;
82
78
if (!$ path1 && !$ path2 ) {
83
- return "" ;
79
+ $ finalPath = "" ;
84
80
} else if (!$ path1 ) {
85
- return $ path2 ;
81
+ $ finalPath = $ path2 ;
86
82
} else if (!$ path2 ) {
87
- return $ path1 ;
83
+ $ finalPath = $ path1 ;
88
84
} else {
89
- return $ path1 . $ final_delim . $ path2 ;
85
+ $ finalPath = $ path1 . $ final_delim . $ path2 ;
86
+ }
87
+
88
+ //preserve the root (Linux, Mac)
89
+ $ startChar = substr ($ path1Orig , 0 , 1 );
90
+ if ($ startChar == $ root_delim ) {
91
+ $ finalPath = $ root_delim . $ finalPath ;
90
92
}
93
+
94
+ return $ finalPath ;
91
95
}
92
96
93
97
}
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ public function test_preserve_root_delimiter_first_arg() {
69
69
$ this ->assertEquals ("/abc " , PI ::joinPath ("/abc/ " , "" ));
70
70
$ this ->assertEquals ("/abc " , PI ::joinPath ("/abc/ " , null ));
71
71
72
+ $ this ->assertEquals ("/abc " , PI ::joinPath ("/ " , "abc " ));
73
+ $ this ->assertEquals ("/abc " , PI ::joinPath ("/ " , "/abc " ));
74
+
72
75
$ this ->assertEquals ("/abc/d " , PI ::joinPath ("/abc " , "d " ));
73
76
$ this ->assertEquals ("/abc/d " , PI ::joinPath ("/abc " , "/d " ));
74
77
}
You can’t perform that action at this time.
0 commit comments