BrowseHelper { public static String getAbsURL(String currentUrl, String subUrl) { String replacedUrl = subUrl.trim(); try { UURI base = UURIFactory.getInstance(currentUrl); UURI absUURI = UURIFactory.getInstance(base, replacedUrl); URI uri = null; try { uri = new URI(replacedUrl); } catch(URISyntaxException uriEx) { String strUri = URLEncoder.encode(replacedUrl, "UTF-8"); Pattern p = Pattern.compile("%23"); Matcher m = p.matcher(strUri); uri = new URI(m.replaceFirst("#")); } String fragment = uri.getFragment(); if (fragment==null) { return absUURI.getEscapedURI(); } else { return absUURI.getEscapedURI() + "#" + fragment; } } catch(Exception ex) { log.error("Error parsing URI '"+replacedUrl+"': ", ex); return null; } }  void setPrefix(String prefix); void setContentTypePatterns(Map<String, List<String>> patterns); void setHtmlTagPatterns(List<String> patterns); static Pattern getTagMagixPattern(String tag, String attr); boolean isReplaceable(String contentType); void fix(StringBuilder content, String contentType, long hrOid, String currentResource); String convertUrl(Long hrOid, String currentResource, String urlToConvert); static String getAbsURL(String currentUrl, String subUrl); void setUrlConversionReplacements(List<StringReplacer> urlConversionReplacements); void insertAtStartOfHead(StringBuilder sb, String toInsert); void insertAtEndOfBody(StringBuilder sb, String toInsert); void insertAtStartOfBody(StringBuilder sb, String toInsert); boolean isUseUrlConversionReplacements(); void setUseUrlConversionReplacements(boolean useUrlConversionReplacements);  }
@Test public final void testGetAbsURL() { String url; url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("mailto:book@bats.co.nz?subject=Booking:%20Destination:%20Death&amp;body=PLEASE%20INCLUDE1.%20your%20name%20:%202.%20your%20phone%20number%20:%203.%20the%20date%20of%20the%20show%20you%20are%20attending%20:%204.%20the%20number%20of%20tickets%20you%20would%20like%20:%20thank%20you.", url); url = BrowseHelper.getAbsURL("http: assertNotNull(url); assertEquals("http: }