MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / toURI

Method toURI

src/main/java/org/htmlunit/util/UrlUtils.java:1320–1345  ·  view source on GitHub ↗

Constructs a URI using the specified URL. @param url the URL @param query the query @throws URISyntaxException If both a scheme and a path are given but the path is relative, if the URI string constructed from the given components violates RFC 2396, or if the a

(final URL url, final String query)

Source from the content-addressed store, hash-verified

1318 * @return the URI
1319 */
1320 public static URI toURI(final URL url, final String query) throws URISyntaxException {
1321 final String scheme = url.getProtocol();
1322 final String host = url.getHost();
1323 final int port = url.getPort();
1324 final String path = url.getPath();
1325 final StringBuilder buffer = new StringBuilder();
1326 if (host != null) {
1327 if (scheme != null) {
1328 buffer.append(scheme).append("://");
1329 }
1330 buffer.append(host);
1331 if (port > 0) {
1332 buffer.append(':').append(port);
1333 }
1334 }
1335 if (path == null || path.isEmpty() || path.charAt(0) != '/') {
1336 buffer.append('/');
1337 }
1338 if (path != null) {
1339 buffer.append(path);
1340 }
1341 if (query != null) {
1342 buffer.append('?').append(query);
1343 }
1344 return new URI(buffer.toString());
1345 }
1346
1347 /**
1348 * @param part the part to encode

Callers 15

makeHttpMethodMethod · 0.95
loadFilePageEncodedMethod · 0.80
loadContentMethod · 0.80
widthHeightWithSourceMethod · 0.80
sendLocalFileMethod · 0.80
sendLocalFileAsyncMethod · 0.80
sendLocalFileAllowedMethod · 0.80
readAsDataURLUnknownMethod · 0.80

Calls 7

isEmptyMethod · 0.65
getProtocolMethod · 0.45
getHostMethod · 0.45
getPortMethod · 0.45
getPathMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45

Tested by 15

loadFilePageEncodedMethod · 0.64
loadContentMethod · 0.64
widthHeightWithSourceMethod · 0.64
sendLocalFileMethod · 0.64
sendLocalFileAsyncMethod · 0.64
sendLocalFileAllowedMethod · 0.64
readAsDataURLUnknownMethod · 0.64