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

Method normalize

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

Helper that constructs a normalized url string usable as cache key. @param url a URL object @return the normalized string

(final URL url)

Source from the content-addressed store, hash-verified

1276 * @return the normalized string
1277 */
1278 public static String normalize(final URL url) {
1279 final StringBuilder result = new StringBuilder();
1280 result.append(url.getProtocol())
1281 .append("://")
1282 .append(url.getHost())
1283 .append(':')
1284 .append((url.getPort() == -1) ? url.getDefaultPort() : url.getPort());
1285
1286 // Compare the files.
1287 String f = url.getFile();
1288 if (f.isEmpty()) {
1289 result.append('/');
1290 }
1291 else {
1292 if (f.indexOf('.') > 0) {
1293 try {
1294 f = url.toURI().normalize().toURL().getFile();
1295 }
1296 catch (final Exception ignored) {
1297 // ignore
1298 }
1299 }
1300 result.append(f);
1301 }
1302
1303 return result.toString();
1304 }
1305
1306 /**
1307 * Constructs a {@link URI} using the specified URL.

Callers 4

normalizeMethod · 0.95
cacheIfPossibleMethod · 0.95
getCacheEntryMethod · 0.95
sameFileMethod · 0.45

Calls 9

getFileMethod · 0.80
toURIMethod · 0.80
isEmptyMethod · 0.65
appendMethod · 0.45
getProtocolMethod · 0.45
getHostMethod · 0.45
getPortMethod · 0.45
indexOfMethod · 0.45
toStringMethod · 0.45

Tested by 1

normalizeMethod · 0.76