@Test public void replaceSubdomain_replacesNothingWhenSubdomainIsEmpty() { URI replacedURI = UriUtil.replaceSubdomain(tokenEndpointUri, ""); assertThat(replacedURI, is(tokenEndpointUri)); }
public static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain) { Assertions.assertNotNull(uri, "the uri parameter must not be null"); if (hasText(subdomain) && hasSubdomain(uri)) { String newHost = subdomain + uri.getHost().substring(uri.getHost().indexOf('.')); try { return uri.resolve(new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment())); } catch (URISyntaxException e) { logger.error("Could not replace subdomain {} in given uri {}", subdomain, uri); throw new IllegalArgumentException(e); } } logger.info("the subdomain of the URI '{}' is not replaced by subdomain '{}'", uri, subdomain); return uri; }
UriUtil { public static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain) { Assertions.assertNotNull(uri, "the uri parameter must not be null"); if (hasText(subdomain) && hasSubdomain(uri)) { String newHost = subdomain + uri.getHost().substring(uri.getHost().indexOf('.')); try { return uri.resolve(new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment())); } catch (URISyntaxException e) { logger.error("Could not replace subdomain {} in given uri {}", subdomain, uri); throw new IllegalArgumentException(e); } } logger.info("the subdomain of the URI '{}' is not replaced by subdomain '{}'", uri, subdomain); return uri; } }
UriUtil { public static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain) { Assertions.assertNotNull(uri, "the uri parameter must not be null"); if (hasText(subdomain) && hasSubdomain(uri)) { String newHost = subdomain + uri.getHost().substring(uri.getHost().indexOf('.')); try { return uri.resolve(new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment())); } catch (URISyntaxException e) { logger.error("Could not replace subdomain {} in given uri {}", subdomain, uri); throw new IllegalArgumentException(e); } } logger.info("the subdomain of the URI '{}' is not replaced by subdomain '{}'", uri, subdomain); return uri; } private  UriUtil(); }
UriUtil { public static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain) { Assertions.assertNotNull(uri, "the uri parameter must not be null"); if (hasText(subdomain) && hasSubdomain(uri)) { String newHost = subdomain + uri.getHost().substring(uri.getHost().indexOf('.')); try { return uri.resolve(new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment())); } catch (URISyntaxException e) { logger.error("Could not replace subdomain {} in given uri {}", subdomain, uri); throw new IllegalArgumentException(e); } } logger.info("the subdomain of the URI '{}' is not replaced by subdomain '{}'", uri, subdomain); return uri; } private  UriUtil(); static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain); @Nonnull static URI expandPath(URI baseUri, String pathToAppend); }
UriUtil { public static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain) { Assertions.assertNotNull(uri, "the uri parameter must not be null"); if (hasText(subdomain) && hasSubdomain(uri)) { String newHost = subdomain + uri.getHost().substring(uri.getHost().indexOf('.')); try { return uri.resolve(new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment())); } catch (URISyntaxException e) { logger.error("Could not replace subdomain {} in given uri {}", subdomain, uri); throw new IllegalArgumentException(e); } } logger.info("the subdomain of the URI '{}' is not replaced by subdomain '{}'", uri, subdomain); return uri; } private  UriUtil(); static URI replaceSubdomain(@Nonnull URI uri, @Nullable String subdomain); @Nonnull static URI expandPath(URI baseUri, String pathToAppend);  }