public String encodePath(String path) {
        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < path.length(); i++) {
            int index = path.indexOf('/', i);
            if (index == -1) {
                builder.append(encodePathSegment(path.substring(i)));
                break;
            }

            builder.append(encodePathSegment(path.substring(i, index)));
            builder.append("/");
            i = index;
        }

        return builder.toString();
    }
Universal, non case-sensitive, protocol-agnostic URL pattern
storage/src/main/java/com/epam/aidial/core/storage/util/UrlUtil.java