UaaUrlUtils { public static String getSubdomain(String subdomain) { if (hasText(subdomain)) { subdomain = subdomain.trim(); subdomain = subdomain.endsWith(".") ? subdomain : subdomain + "."; } return subdomain; }  static String getUaaUrl(String path, IdentityZone currentIdentityZone); static String getUaaUrl(String path, boolean zoneSwitchPossible, IdentityZone currentIdentityZone); static String getUaaHost(IdentityZone currentIdentityZone); static boolean isValidRegisteredRedirectUrl(String url); static boolean isValidSubdomain(String subdomain); static String findMatchingRedirectUri(Collection<String> redirectUris, String requestedRedirectUri, String fallbackRedirectUri); static String getHostForURI(String uri); static String getBaseURL(HttpServletRequest request); static Map<String, String[]> getParameterMap(String uri); static boolean isUrl(String url); static String addQueryParameter(String url, String name, String value); static String addFragmentComponent(String urlString, String component); static String addSubdomainToUrl(String url, String subdomain); static String getSubdomain(String subdomain); static String extractPathVariableFromUrl(int pathParameterIndex, String path); static String getRequestPath(HttpServletRequest request); static boolean uriHasMatchingHost(String uri, String hostname); static String normalizeUri(String uri);  }
@Test void getSubdomain() { assertThat(UaaUrlUtils.getSubdomain(null), is(nullValue())); assertThat(UaaUrlUtils.getSubdomain(""), is("")); assertThat(UaaUrlUtils.getSubdomain(" "), is(" ")); assertThat(UaaUrlUtils.getSubdomain("a"), is("a.")); assertThat(UaaUrlUtils.getSubdomain(" z "), is("z.")); assertThat(UaaUrlUtils.getSubdomain("a.b.c.d.e"), is("a.b.c.d.e.")); }