diff options
author | Luciano Chavez <lnx1138@us.ibm.com> | 2008-01-21 20:08:38 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2008-01-21 20:08:38 +0000 |
commit | e0c604077e768a96985f4848b756d708564b22eb (patch) | |
tree | ca7c99d5b15a1c34e9dd56c8cf949b30f65c4b65 /libjava/classpath/java/net/URI.java | |
parent | d68e117b15c0313115ee8649387927c876756fab (diff) | |
download | gcc-e0c604077e768a96985f4848b756d708564b22eb.zip gcc-e0c604077e768a96985f4848b756d708564b22eb.tar.gz gcc-e0c604077e768a96985f4848b756d708564b22eb.tar.bz2 |
re PR libgcj/34369 (java.net.URI.relativize(URI) method returns incorrect results)
2008-01-21 Luciano Chavez <lnx1138@us.ibm.com>
PR libgcj/34369:
* java/net/URI.java (relativize): Check initial segment for
trailing "/".
From-SVN: r131701
Diffstat (limited to 'libjava/classpath/java/net/URI.java')
-rw-r--r-- | libjava/classpath/java/net/URI.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libjava/classpath/java/net/URI.java b/libjava/classpath/java/net/URI.java index 43b10fc..4bf4db9 100644 --- a/libjava/classpath/java/net/URI.java +++ b/libjava/classpath/java/net/URI.java @@ -1,5 +1,5 @@ /* URI.java -- An URI class - Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -968,12 +968,18 @@ public final class URI return uri; if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority()))) return uri; - if (!(uri.getRawPath().startsWith(rawPath))) - return uri; + String basePath = rawPath; + if (!(uri.getRawPath().equals(rawPath))) + { + if (!(basePath.endsWith("/"))) + basePath = basePath.concat("/"); + if (!(uri.getRawPath().startsWith(basePath))) + return uri; + } try { return new URI(null, null, - uri.getRawPath().substring(rawPath.length()), + uri.getRawPath().substring(basePath.length()), uri.getRawQuery(), uri.getRawFragment()); } catch (URISyntaxException e) |