File tree 2 files changed +7
-4
lines changed
main/kotlin/com/coder/gateway/util
test/kotlin/com/coder/gateway/util
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ fun expand(path: String): String {
31
31
if (path == " ~" || path == " \$ HOME" || path == " \$ {user.home}" ) {
32
32
return System .getProperty(" user.home" )
33
33
}
34
- if (path.startsWith(" ~" + File .separator )) {
34
+ if (path.startsWith(" ~/ " ) || path.startsWith( " ~ \\ " )) {
35
35
return Path .of(System .getProperty(" user.home" ), path.substring(1 )).toString()
36
36
}
37
- if (path.startsWith(" \$ HOME" + File .separator )) {
37
+ if (path.startsWith(" \$ HOME/ " ) || path.startsWith( " \$ HOME \\ " )) {
38
38
return Path .of(System .getProperty(" user.home" ), path.substring(5 )).toString()
39
39
}
40
- if (path.startsWith(" \$ {user.home}" + File .separator )) {
40
+ if (path.startsWith(" \$ {user.home}/ " || path.startsWith( " \$ {user.home} \\ " ) )) {
41
41
return Path .of(System .getProperty(" user.home" ), path.substring(12 )).toString()
42
42
}
43
43
return path
Original file line number Diff line number Diff line change @@ -107,8 +107,11 @@ internal class PathExtensionsTest {
107
107
108
108
// Do not replace if part of a larger string.
109
109
assertEquals(home, expand(it))
110
- assertEquals(home, expand(it + File .separator))
110
+ assertEquals(home, expand(it + " /" ))
111
+ assertEquals(home, expand(it + " \\ " ))
111
112
assertEquals(it + " hello" , expand(it + " hello" ))
113
+ assertEquals(it + " hello/foo" , expand(it + " hello/foo" ))
114
+ assertEquals(it + " hello\\ foo" , expand(it + " hello\\ foo" ))
112
115
}
113
116
}
114
117
}
You can’t perform that action at this time.
0 commit comments