@Test public void singleQuoteBasePath() throws MalformedURLException { String expectedUrl = "https: String baseUri = "https: String relativePath = "%D7%90%D7%91%D7%92%D7%93"; UriResolver resolver = new UriResolver(baseUri); Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); }
public URL resolveAgainstBaseUri(String uriString) throws MalformedURLException { URL resolvedUrl = null; uriString = uriString.trim(); uriString = UriEncodeUtil.encode(uriString); if (isLocalBaseUri) { if (!uriString.startsWith("file:")) { try { Path path = Paths.get(uriString); if (path.isAbsolute()) { resolvedUrl = path.toUri().toURL(); } } catch (Exception ignored) { } } } if (resolvedUrl == null) { resolvedUrl = new URL(baseUrl, uriString); } return resolvedUrl; }
UriResolver { public URL resolveAgainstBaseUri(String uriString) throws MalformedURLException { URL resolvedUrl = null; uriString = uriString.trim(); uriString = UriEncodeUtil.encode(uriString); if (isLocalBaseUri) { if (!uriString.startsWith("file:")) { try { Path path = Paths.get(uriString); if (path.isAbsolute()) { resolvedUrl = path.toUri().toURL(); } } catch (Exception ignored) { } } } if (resolvedUrl == null) { resolvedUrl = new URL(baseUrl, uriString); } return resolvedUrl; } }
UriResolver { public URL resolveAgainstBaseUri(String uriString) throws MalformedURLException { URL resolvedUrl = null; uriString = uriString.trim(); uriString = UriEncodeUtil.encode(uriString); if (isLocalBaseUri) { if (!uriString.startsWith("file:")) { try { Path path = Paths.get(uriString); if (path.isAbsolute()) { resolvedUrl = path.toUri().toURL(); } } catch (Exception ignored) { } } } if (resolvedUrl == null) { resolvedUrl = new URL(baseUrl, uriString); } return resolvedUrl; } UriResolver(String baseUri); }
UriResolver { public URL resolveAgainstBaseUri(String uriString) throws MalformedURLException { URL resolvedUrl = null; uriString = uriString.trim(); uriString = UriEncodeUtil.encode(uriString); if (isLocalBaseUri) { if (!uriString.startsWith("file:")) { try { Path path = Paths.get(uriString); if (path.isAbsolute()) { resolvedUrl = path.toUri().toURL(); } } catch (Exception ignored) { } } } if (resolvedUrl == null) { resolvedUrl = new URL(baseUrl, uriString); } return resolvedUrl; } UriResolver(String baseUri); String getBaseUri(); URL resolveAgainstBaseUri(String uriString); boolean isLocalBaseUri(); }
UriResolver { public URL resolveAgainstBaseUri(String uriString) throws MalformedURLException { URL resolvedUrl = null; uriString = uriString.trim(); uriString = UriEncodeUtil.encode(uriString); if (isLocalBaseUri) { if (!uriString.startsWith("file:")) { try { Path path = Paths.get(uriString); if (path.isAbsolute()) { resolvedUrl = path.toUri().toURL(); } } catch (Exception ignored) { } } } if (resolvedUrl == null) { resolvedUrl = new URL(baseUrl, uriString); } return resolvedUrl; } UriResolver(String baseUri); String getBaseUri(); URL resolveAgainstBaseUri(String uriString); boolean isLocalBaseUri();  }