411 |
* @param url2 The second URL. |
* @param url2 The second URL. |
412 |
* |
* |
413 |
* @return True if both URLs contain the same host. |
* @return True if both URLs contain the same host. |
|
* |
|
|
* @exception UnknownHostException If an unknown host is found |
|
414 |
*/ |
*/ |
415 |
protected boolean hostsEqual(URL url1, URL url2) |
protected boolean hostsEqual(URL url1, URL url2) |
416 |
{ |
{ |
515 |
sb.append(":"); |
sb.append(":"); |
516 |
} |
} |
517 |
|
|
518 |
if (authority.length() != 0) |
// If we have superfluous leading slashes (that means, at least 2) |
519 |
{ |
// we always add the authority component ("//" + host) to |
520 |
sb.append("//").append(authority); |
// avoid ambiguity. Otherwise we would generate an URL like |
521 |
} |
// proto://home/foo |
522 |
|
// where we meant: |
523 |
sb.append(file); |
// host: <empty> - file: //home/foo |
524 |
|
// but URL spec says it is: |
525 |
|
// host: home - file: /foo |
526 |
|
if (authority.length() != 0 || file.startsWith("//") ) |
527 |
|
sb.append("//").append(authority).append(file); |
528 |
|
else |
529 |
|
sb.append(file); |
530 |
|
|
531 |
if (ref != null) |
if (ref != null) |
532 |
sb.append('#').append(ref); |
sb.append('#').append(ref); |