static String getBasePath(URL url) {
        if (url == null) {
            return null;
        }

        String s = url.toString();
        if (s.startsWith(FILE_SCHEME) && !s.startsWith("file://")) {
            s = "file://" + s.substring(FILE_SCHEME.length());
        }

        if (s.endsWith("/") || StrTry.isEmpty(url.getPath())) {
            return s;
        } else {
            return s.substring(0, s.lastIndexOf("/") + 1);
        }
    }