public static String join(String endpoint, String path) {
        if (endpoint == null || endpoint.isEmpty())
            return path;
        if (path == null || path.isEmpty())
            return endpoint;

        if (StringUtils.endsWith(endpoint, "/") && path.startsWith("/")) {
            return endpoint + path.substring(1);
        } else if (StringUtils.endsWith(endpoint, "/") ^ path.startsWith("/")) {
            return endpoint + path;
        }
        return endpoint + "/" + path;
    }
Join endpoint and path with sensible / behaviour.

@param endpoint the endpoint
@param path the destination (path)
@return the joined endpoint + destination.
common/util/src/main/java/io/apiman/common/util/ApimanPathUtils.java