@Test public void testConcatUrls() { assertEquals("/", UrlUtils.concatUrlPaths(null, null)); assertEquals("/", UrlUtils.concatUrlPaths(null, "")); assertEquals("/", UrlUtils.concatUrlPaths("", null)); assertEquals("/", UrlUtils.concatUrlPaths("", "")); assertEquals("/a/b", UrlUtils.concatUrlPaths("a", "b")); assertEquals("/a/b", UrlUtils.concatUrlPaths("/a", "/b")); }
public static String concatUrlPaths(final String base, final String path) { if (base == null && path == null) { return "/"; } String result; if (base == null) { result = path; } else if (path == null) { result = base; } else { result = base + "/" + path; } result = result.replaceAll("/+", "/"); if (result.endsWith("/")) { result = result.substring(0, result.length() - 1); } if (!result.startsWith("/")) { result = "/" + result; } return result; }
UrlUtils { public static String concatUrlPaths(final String base, final String path) { if (base == null && path == null) { return "/"; } String result; if (base == null) { result = path; } else if (path == null) { result = base; } else { result = base + "/" + path; } result = result.replaceAll("/+", "/"); if (result.endsWith("/")) { result = result.substring(0, result.length() - 1); } if (!result.startsWith("/")) { result = "/" + result; } return result; } }
UrlUtils { public static String concatUrlPaths(final String base, final String path) { if (base == null && path == null) { return "/"; } String result; if (base == null) { result = path; } else if (path == null) { result = base; } else { result = base + "/" + path; } result = result.replaceAll("/+", "/"); if (result.endsWith("/")) { result = result.substring(0, result.length() - 1); } if (!result.startsWith("/")) { result = "/" + result; } return result; } UrlUtils(); }
UrlUtils { public static String concatUrlPaths(final String base, final String path) { if (base == null && path == null) { return "/"; } String result; if (base == null) { result = path; } else if (path == null) { result = base; } else { result = base + "/" + path; } result = result.replaceAll("/+", "/"); if (result.endsWith("/")) { result = result.substring(0, result.length() - 1); } if (!result.startsWith("/")) { result = "/" + result; } return result; } UrlUtils(); static String concatUrlPaths(final String base, final String path); static Map<String, String> urlDecodeParams(final String str); static MultivaluedMap<String, String> urlDecodeMultivaluedParams(final String str); static String urlEncodeParams(final Map<String, String> params); static String urlEncodeMultivaluedParams(final MultivaluedMap<String, String> params); static String urlEncode(final String str); static String urlDecode(final String str); static String urlEncode(final String str, final boolean ignoreTemplates, final boolean ignoreSlashes); }
UrlUtils { public static String concatUrlPaths(final String base, final String path) { if (base == null && path == null) { return "/"; } String result; if (base == null) { result = path; } else if (path == null) { result = base; } else { result = base + "/" + path; } result = result.replaceAll("/+", "/"); if (result.endsWith("/")) { result = result.substring(0, result.length() - 1); } if (!result.startsWith("/")) { result = "/" + result; } return result; } UrlUtils(); static String concatUrlPaths(final String base, final String path); static Map<String, String> urlDecodeParams(final String str); static MultivaluedMap<String, String> urlDecodeMultivaluedParams(final String str); static String urlEncodeParams(final Map<String, String> params); static String urlEncodeMultivaluedParams(final MultivaluedMap<String, String> params); static String urlEncode(final String str); static String urlDecode(final String str); static String urlEncode(final String str, final boolean ignoreTemplates, final boolean ignoreSlashes);  }