diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
commit | 8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java/net/URLStreamHandler.java | |
parent | 02e549bfaaec38f68307e7f34e46ea57ea1809af (diff) | |
download | gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
Diffstat (limited to 'libjava/classpath/java/net/URLStreamHandler.java')
-rw-r--r-- | libjava/classpath/java/net/URLStreamHandler.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/libjava/classpath/java/net/URLStreamHandler.java b/libjava/classpath/java/net/URLStreamHandler.java index 57ce2dfa290..ed95092219e 100644 --- a/libjava/classpath/java/net/URLStreamHandler.java +++ b/libjava/classpath/java/net/URLStreamHandler.java @@ -411,8 +411,6 @@ public abstract class URLStreamHandler * @param url2 The second URL. * * @return True if both URLs contain the same host. - * - * @exception UnknownHostException If an unknown host is found */ protected boolean hostsEqual(URL url1, URL url2) { @@ -511,18 +509,24 @@ public abstract class URLStreamHandler int size = protocol.length() + authority.length() + file.length() + 24; StringBuffer sb = new StringBuffer(size); - if (protocol != null && protocol.length() > 0) + if (protocol.length() > 0) { sb.append(protocol); sb.append(":"); } - if (authority.length() != 0) - { - sb.append("//").append(authority); - } - - sb.append(file); + // If we have superfluous leading slashes (that means, at least 2) + // we always add the authority component ("//" + host) to + // avoid ambiguity. Otherwise we would generate an URL like + // proto://home/foo + // where we meant: + // host: <empty> - file: //home/foo + // but URL spec says it is: + // host: home - file: /foo + if (authority.length() != 0 || file.startsWith("//") ) + sb.append("//").append(authority).append(file); + else + sb.append(file); if (ref != null) sb.append('#').append(ref); |