Adds a test case for WebAddress where the path component does not have a leading slash
When a URL is malformed because the path does not start with a slash,
we assume that the path starts with the first character that is not
valid in the host and insert a leading slash. This is the reason why
the regex for the path component does not force a leading slash.
Bug: 1011602
Change-Id: I8efe46c058d2ee2d1a6a4406ee25dc021315222b
diff --git a/core/tests/coretests/src/android/net/UriTest.java b/core/tests/coretests/src/android/net/UriTest.java
index 60c3c76..c8ad60d 100644
--- a/core/tests/coretests/src/android/net/UriTest.java
+++ b/core/tests/coretests/src/android/net/UriTest.java
@@ -285,6 +285,7 @@
assertEquals("d", uri.getQueryParameter("c"));
}
+ // http://b/2337042
@SmallTest
public void testHostWithTrailingDot() {
Uri uri = Uri.parse("http://google.com./b/c/g");
diff --git a/core/tests/coretests/src/android/net/WebAddressTest.java b/core/tests/coretests/src/android/net/WebAddressTest.java
index 7ca1e62..f0af35d 100644
--- a/core/tests/coretests/src/android/net/WebAddressTest.java
+++ b/core/tests/coretests/src/android/net/WebAddressTest.java
@@ -22,10 +22,19 @@
public class WebAddressTest extends TestCase {
+ // http://b/2337042
@SmallTest
public void testHostWithTrailingDot() {
WebAddress webAddress = new WebAddress("http://google.com./b/c/g");
assertEquals("google.com.", webAddress.mHost);
assertEquals("/b/c/g", webAddress.mPath);
}
+
+ // http://b/1011602
+ @SmallTest
+ public void testPathWithoutLeadingSlash() {
+ WebAddress webAddress = new WebAddress("http://www.myspace.com?si=1");
+ assertEquals("www.myspace.com", webAddress.mHost);
+ assertEquals("/?si=1", webAddress.mPath);
+ }
}