public static String createApiUrl(String baseUrl, String... segments) {
        if(Arrays.stream(segments).anyMatch(Objects::isNull)) {
            return null;
        }

        var path = Arrays.stream(segments)
                .filter(StringUtils::isNotEmpty)
                .map(segment -> UriUtils.encodePathSegment(segment, StandardCharsets.UTF_8))
                .collect(Collectors.joining("/"));

        if (baseUrl.isEmpty() || baseUrl.charAt(baseUrl.length() - 1) != '/') {
            baseUrl += '/';
        }

        return baseUrl + path;
    }
@Test
    public void testApiUrl() throws Exception {
        var baseUrl = "http://localhost/";
        assertThat(UrlUtil.createApiUrl(baseUrl, "api", "foo", "b\ta/r"))
                .isEqualTo("http://localhost/api/foo/b%09a%2Fr");
    }