UrlUtil { public static String constructRelativeUrl(String theParentExtensionUrl, String theExtensionUrl) { if (theParentExtensionUrl == null) { return theExtensionUrl; } if (theExtensionUrl == null) { return theExtensionUrl; } int parentLastSlashIdx = theParentExtensionUrl.lastIndexOf('/'); int childLastSlashIdx = theExtensionUrl.lastIndexOf('/'); if (parentLastSlashIdx == -1 || childLastSlashIdx == -1) { return theExtensionUrl; } if (parentLastSlashIdx != childLastSlashIdx) { return theExtensionUrl; } if (!theParentExtensionUrl.substring(0, parentLastSlashIdx).equals(theExtensionUrl.substring(0, parentLastSlashIdx))) { return theExtensionUrl; } if (theExtensionUrl.length() > parentLastSlashIdx) { return theExtensionUrl.substring(parentLastSlashIdx + 1); } return theExtensionUrl; }  static String constructAbsoluteUrl(String theBase, String theEndpoint); static boolean isAbsolute(String theValue); static String constructRelativeUrl(String theParentExtensionUrl, String theExtensionUrl); static boolean isValid(String theUrl); static String unescape(String theString);  }
@Test public void testConstructRelativeUrl() { assertEquals("http: assertEquals("http: assertEquals("baz", UrlUtil.constructRelativeUrl("http: }