Commit c2c1c8a7 authored by yanzg's avatar yanzg

Merge branch 'ver1.1' of http://192.168.0.204/yzg/yzg-util

parents 7157c77b edc462c2
......@@ -188,6 +188,47 @@ public class UrlHelper {
return mapRequest;
}
/**
* 获取全路径
*
* @param simpleUrl 简短路径或全路径
* @param simpleBaseUrl 配置后的基础路径
* @param defBaseUrl 默认路径
*/
public static String getFullUrl(String simpleUrl, String simpleBaseUrl, String defBaseUrl) {
// 获取请求地址
String tbdUrl = StringHelper.getFirst(simpleBaseUrl, defBaseUrl);
// 获取全路径
String toSimpleFullUrl = getFUllUrl(tbdUrl, simpleUrl);
// 最终地址处理
String toSimpleUrl;
if (!StringHelper.compare(simpleBaseUrl, simpleUrl) && toSimpleFullUrl.startsWith(defBaseUrl)) {
String rightUrl = StringHelper.trimStart(toSimpleFullUrl, defBaseUrl);
toSimpleUrl = getFUllUrl(tbdUrl, rightUrl);
} else {
toSimpleUrl = toSimpleFullUrl;
}
return toSimpleUrl;
}
/**
* 获取全路径
*
* @param baseUrl 基础路径
* @param simpleUrl 简单路径
* @return 全路径
*/
private static String getFUllUrl(String baseUrl, String simpleUrl) {
String toSimpleFullUrl;
if (simpleUrl.startsWith("http://") || simpleUrl.startsWith("https://")) {
toSimpleFullUrl = simpleUrl;
} else {
toSimpleFullUrl = StringHelper.trimEnd(baseUrl, "/") + "/" + StringHelper.trimStart(simpleUrl, "/");
}
return toSimpleFullUrl;
}
/**
public static void main(String[] args) {
String url = "http://wx.pangdly.com/#/orderPayment?companyId=6da527f930be4aa1904fe17fcb41874f&order=z001570428580820822894116f754e96";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment