com.github.zhengframework.web.PathUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zheng-web Show documentation
Show all versions of zheng-web Show documentation
zheng framework module: web server
package com.github.zhengframework.web;
import com.google.common.base.Joiner;
public class PathUtils {
public static String fixPath(String... paths) {
String path = Joiner.on("/").skipNulls().join(paths);
path = path.replaceAll("[/]+", "/");
if ("/".equals(path)) {
path = "";
} else if(path.length() > 1) {
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
if (!path.startsWith("/")) {
path = "/" + path;
}
}
return path;
}
}