/** * If the url appears relative to an authority, i.e. it starts with "/", then convert it to be * absolute using the server URL (including context path) provided by the ServerService. * * @param url a context-relative url path to convert into absolute url. * @return absolute URL if input was a url path, otherwise returns the input string. */ String makeContextAbsoluteURL(String url) { if (null != url && url.startsWith("/")) { // change relative URL into absolute using the base server URL try { final URL newUrl = new URL(serverService.getConnParams().getServerUrl() + url); url = newUrl.toExternalForm(); } catch (MalformedURLException e) { e.printStackTrace(); } } return url; }