I don't think this is a bug. Everything to the
right of the final "/" in the original URI is discarded when resolving
against any relative URI.

So, "foo#bar" is correctly discarded, leaving the new URI

http://example.com/

That would be my reading of RFC2396 anyway.

- Michael.

Jack Bates wrote:
new URI("http://example.com/foo#bar";).resolve("")

^ I expect this to return "http://example.com/foo";, but when I run,

import java.net.URI;

public class Test
{
  public static void main(String[] args) throws Exception
  {
    System.out.println(new URI("http://example.com/foo#bar";).resolve(""));
  }
}

- it outputs,

$ java Test
http://example.com/
$
Do you think this is a bug?

I'm running OpenJDK 6, but I can find only cosmetic differences between
URI.java in the version I'm running and URI.java in,
http://www.java.net/download/openjdk/jdk7/promoted/b80/openjdk-7-ea-src-b80-21_jan_2010.zip

- so I assume the issue (if it is an issue) still exists?

Reply via email to