代码拉取完成,页面将自动刷新
27
提供URL相对地址转绝对地址的方法
开启的
https://gitee.com/huangxiaohan1117/spider-flow/issues/I2M9CI
@Comment("url相对地址转绝对地址")
@Example("${url.absolute('http://www.example.com/abc/index.html','./abs.html')}")
@Return({String.class})
public static String absolute(String baseUrl, String relativeUrl) {
String result = null;
try {
URI baseUri = new URI(baseUrl);
URI absoluteUri = baseUri.resolve(relativeUrl);
// 屏蔽转URL,防止在baseUrl时无http(s)://的 protocol 导致的转换错误, 此时也可以处理 ws:// 等其他非http开头的地址
/*URL absoluteUrl = absoluteUri.toURL();
result = absoluteUrl.toString();*/
result = absoluteUri.toString();
} catch (Exception e) {
//
}
return result;
}