@Test void testToURIHttpsNoPort() { URI jobServiceURL = URIBuilder.toURI("https: assertHttp(jobServiceURL, "https", 443); }
public static URI toURI(String urlStr) { try { final URL url = new URL(urlStr); final Integer port = Optional.of(url.getPort()).filter(p -> !p.equals(-1)).orElse(url.getDefaultPort()); final URI uri = url.toURI(); return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException("Not valid URI: " + urlStr, e); } }
URIBuilder { public static URI toURI(String urlStr) { try { final URL url = new URL(urlStr); final Integer port = Optional.of(url.getPort()).filter(p -> !p.equals(-1)).orElse(url.getDefaultPort()); final URI uri = url.toURI(); return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException("Not valid URI: " + urlStr, e); } } }
URIBuilder { public static URI toURI(String urlStr) { try { final URL url = new URL(urlStr); final Integer port = Optional.of(url.getPort()).filter(p -> !p.equals(-1)).orElse(url.getDefaultPort()); final URI uri = url.toURI(); return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException("Not valid URI: " + urlStr, e); } } private  URIBuilder(); }
URIBuilder { public static URI toURI(String urlStr) { try { final URL url = new URL(urlStr); final Integer port = Optional.of(url.getPort()).filter(p -> !p.equals(-1)).orElse(url.getDefaultPort()); final URI uri = url.toURI(); return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException("Not valid URI: " + urlStr, e); } } private  URIBuilder(); static URI toURI(String urlStr); }
URIBuilder { public static URI toURI(String urlStr) { try { final URL url = new URL(urlStr); final Integer port = Optional.of(url.getPort()).filter(p -> !p.equals(-1)).orElse(url.getDefaultPort()); final URI uri = url.toURI(); return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException("Not valid URI: " + urlStr, e); } } private  URIBuilder(); static URI toURI(String urlStr);  }