mirror of
https://github.com/alibaba/testable-mock.git
synced 2026-08-19 09:43:29 +08:00
解决:Windows下文件分隔符替换多重转义的问题,增加本地maven仓库
This commit is contained in:
@@ -5,18 +5,19 @@ public class PathUtil {
|
||||
private static final String PREFIX_WIN = "win";
|
||||
private static final String PROPERTY_OS_NAME = "os.name";
|
||||
private static final String PATH_SPLIT_UNIX = "/";
|
||||
private static final String PATH_SPLIT_WIN = "\\";
|
||||
private static final String PATH_SPLIT_WIN = "\\\\";
|
||||
private static final String PROTOCOL_FILE = "file:/";
|
||||
|
||||
/**
|
||||
* Fit path according to operation system type
|
||||
*
|
||||
* @param path original path
|
||||
* @return fitted path
|
||||
*/
|
||||
public static String fitPathString(String path) {
|
||||
String os = System.getProperty(PROPERTY_OS_NAME);
|
||||
if (os.toLowerCase().startsWith(PREFIX_WIN)) {
|
||||
return path.replaceAll(PATH_SPLIT_UNIX, PATH_SPLIT_WIN);
|
||||
path = path.replaceAll(PATH_SPLIT_UNIX, PATH_SPLIT_WIN);
|
||||
}
|
||||
return path.startsWith(PROTOCOL_FILE) ? path : (PROTOCOL_FILE + path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user