include leading slash in path when parsing URLs in URLStreamHandler

This matches the behavior of OpenJDK's version.
This commit is contained in:
Joel Dice 2012-02-18 15:14:16 -07:00
parent 999e90c332
commit 750e5f903c
2 changed files with 2 additions and 3 deletions

View File

@ -40,7 +40,7 @@ public abstract class URLStreamHandler {
host = s.substring(0, colon); host = s.substring(0, colon);
port = Integer.parseInt(s.substring(colon + 1), slash); port = Integer.parseInt(s.substring(colon + 1), slash);
} }
s = s.substring(slash + 1); s = s.substring(slash);
} }
} }

View File

@ -3,7 +3,7 @@ import java.net.URL;
public class UrlTest { public class UrlTest {
private static String query="var1=val1&var2=val2"; private static String query="var1=val1&var2=val2";
private static String path="testpath"; private static String path="/testpath";
private static String domain="file://www.readytalk.com"; private static String domain="file://www.readytalk.com";
private static String file=path + "?" + query; private static String file=path + "?" + query;
private static URL url; private static URL url;
@ -15,7 +15,6 @@ public class UrlTest {
private static void setupURL() throws MalformedURLException { private static void setupURL() throws MalformedURLException {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(domain); builder.append(domain);
builder.append("/");
builder.append(file); builder.append(file);
url = new URL(builder.toString()); url = new URL(builder.toString());
} }