mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-03-23 16:20:26 +08:00
Merge pull request #37 from Yiniu/master
解决:Windows下文件分隔符替换多重转义,URLCloassLoader路径不合规的问题,增加本地maven仓库
This commit is contained in:
commit
851ae91406
@ -7,6 +7,7 @@ version = '1.0.0-SNAPSHOT'
|
|||||||
sourceCompatibility = '8'
|
sourceCompatibility = '8'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,18 +5,19 @@ public class PathUtil {
|
|||||||
private static final String PREFIX_WIN = "win";
|
private static final String PREFIX_WIN = "win";
|
||||||
private static final String PROPERTY_OS_NAME = "os.name";
|
private static final String PROPERTY_OS_NAME = "os.name";
|
||||||
private static final String PATH_SPLIT_UNIX = "/";
|
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:/";
|
private static final String PROTOCOL_FILE = "file:/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fit path according to operation system type
|
* Fit path according to operation system type
|
||||||
|
*
|
||||||
* @param path original path
|
* @param path original path
|
||||||
* @return fitted path
|
* @return fitted path
|
||||||
*/
|
*/
|
||||||
public static String fitPathString(String path) {
|
public static String fitPathString(String path) {
|
||||||
String os = System.getProperty(PROPERTY_OS_NAME);
|
String os = System.getProperty(PROPERTY_OS_NAME);
|
||||||
if (os.toLowerCase().startsWith(PREFIX_WIN)) {
|
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);
|
return path.startsWith(PROTOCOL_FILE) ? path : (PROTOCOL_FILE + path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user