From 8bb37f7ffb24ab06576dd4225ab0a5e1828a0d07 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 7 Sep 2010 18:33:26 +0100 Subject: [PATCH] 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 --- core/tests/coretests/src/android/net/UriTest.java | 1 + core/tests/coretests/src/android/net/WebAddressTest.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/core/tests/coretests/src/android/net/UriTest.java b/core/tests/coretests/src/android/net/UriTest.java index 60c3c76c01aab..c8ad60d5b7f8d 100644 --- a/core/tests/coretests/src/android/net/UriTest.java +++ b/core/tests/coretests/src/android/net/UriTest.java @@ -285,6 +285,7 @@ public class UriTest extends TestCase { 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 7ca1e6246618b..f0af35d40134c 100644 --- a/core/tests/coretests/src/android/net/WebAddressTest.java +++ b/core/tests/coretests/src/android/net/WebAddressTest.java @@ -22,10 +22,19 @@ import junit.framework.TestCase; 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); + } }