Skip to content

Commit

Permalink
Update XHttpUrlHelper.java
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalgust committed Aug 3, 2024
1 parent 3d02f46 commit ca33f4c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public String getProtocol() {
//



public String mergUrl(URL url, String path) {
String port = url.getPort() < 0 ? "" : ":" + url.getPort();
String prefix = url.getProtocol() + "://" + url.getHost() + port + "/";

String tmppath = url.getPath();
if (tmppath.endsWith("/") || path.startsWith("/") || path.indexOf("/") < 0) {
String relativePath = url.getPath();
relativePath = relativePath.indexOf('/') >= 0 ? relativePath.substring(0, relativePath.lastIndexOf('/')) : "";
if (path.startsWith("/")) {
return prefix + path;
} else {
return prefix + "/" + path.substring(0, path.lastIndexOf("/"));
return prefix + relativePath + "/" + path;
}
}

Expand Down

0 comments on commit ca33f4c

Please sign in to comment.