Loading core/java/android/content/UriMatcher.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class UriMatcher if (path != null) { if (path != null) { String newPath = path; String newPath = path; // Strip leading slash if present. // Strip leading slash if present. if (path.length() > 0 && path.charAt(0) == '/') { if (path.length() > 1 && path.charAt(0) == '/') { newPath = path.substring(1); newPath = path.substring(1); } } tokens = newPath.split("/"); tokens = newPath.split("/"); Loading core/tests/coretests/src/android/net/UriMatcherTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -82,9 +82,31 @@ public class UriMatcherTest extends TestCase { checkAll(matcher); checkAll(matcher); } } @SmallTest public void testContentUrisWithLeadingSlashAndOnlySlash() { UriMatcher matcher = new UriMatcher(ROOT); matcher.addURI("people", "/", PEOPLE); matcher.addURI("people", "/#", PEOPLE_ID); matcher.addURI("people", "/#/phones", PEOPLE_PHONES); matcher.addURI("people", "/#/phones/blah", PEOPLE_PHONES_ID); matcher.addURI("people", "/#/phones/#", PEOPLE_PHONES_ID); matcher.addURI("people", "/#/addresses", PEOPLE_ADDRESSES); matcher.addURI("people", "/#/addresses/#", PEOPLE_ADDRESSES_ID); matcher.addURI("people", "/#/contact-methods", PEOPLE_CONTACTMETH); matcher.addURI("people", "/#/contact-methods/#", PEOPLE_CONTACTMETH_ID); matcher.addURI("calls", "/", CALLS); matcher.addURI("calls", "/#", CALLS_ID); matcher.addURI("caller-id", "/", CALLERID); matcher.addURI("caller-id", "/*", CALLERID_TEXT); matcher.addURI("filter-recent", null, FILTERRECENT); matcher.addURI("auth", "/another/path/segment", ANOTHER_PATH_SEGMENT); checkAll(matcher); } private void checkAll(UriMatcher matcher) { private void checkAll(UriMatcher matcher) { check("content://asdf", UriMatcher.NO_MATCH, matcher); check("content://asdf", UriMatcher.NO_MATCH, matcher); check("content://people", PEOPLE, matcher); check("content://people", PEOPLE, matcher); check("content://people/", PEOPLE, matcher); check("content://people/1", PEOPLE_ID, matcher); check("content://people/1", PEOPLE_ID, matcher); check("content://people/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/2/phones", PEOPLE_PHONES, matcher); check("content://people/2/phones", PEOPLE_PHONES, matcher); Loading @@ -97,9 +119,11 @@ public class UriMatcherTest extends TestCase { check("content://people/2/contact-methods/3", PEOPLE_CONTACTMETH_ID, matcher); check("content://people/2/contact-methods/3", PEOPLE_CONTACTMETH_ID, matcher); check("content://people/2/contact-methods/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/2/contact-methods/asdf", UriMatcher.NO_MATCH, matcher); check("content://calls", CALLS, matcher); check("content://calls", CALLS, matcher); check("content://calls/", CALLS, matcher); check("content://calls/1", CALLS_ID, matcher); check("content://calls/1", CALLS_ID, matcher); check("content://calls/asdf", UriMatcher.NO_MATCH, matcher); check("content://calls/asdf", UriMatcher.NO_MATCH, matcher); check("content://caller-id", CALLERID, matcher); check("content://caller-id", CALLERID, matcher); check("content://caller-id/", CALLERID, matcher); check("content://caller-id/asdf", CALLERID_TEXT, matcher); check("content://caller-id/asdf", CALLERID_TEXT, matcher); check("content://caller-id/1", CALLERID_TEXT, matcher); check("content://caller-id/1", CALLERID_TEXT, matcher); check("content://filter-recent", FILTERRECENT, matcher); check("content://filter-recent", FILTERRECENT, matcher); Loading Loading
core/java/android/content/UriMatcher.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class UriMatcher if (path != null) { if (path != null) { String newPath = path; String newPath = path; // Strip leading slash if present. // Strip leading slash if present. if (path.length() > 0 && path.charAt(0) == '/') { if (path.length() > 1 && path.charAt(0) == '/') { newPath = path.substring(1); newPath = path.substring(1); } } tokens = newPath.split("/"); tokens = newPath.split("/"); Loading
core/tests/coretests/src/android/net/UriMatcherTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -82,9 +82,31 @@ public class UriMatcherTest extends TestCase { checkAll(matcher); checkAll(matcher); } } @SmallTest public void testContentUrisWithLeadingSlashAndOnlySlash() { UriMatcher matcher = new UriMatcher(ROOT); matcher.addURI("people", "/", PEOPLE); matcher.addURI("people", "/#", PEOPLE_ID); matcher.addURI("people", "/#/phones", PEOPLE_PHONES); matcher.addURI("people", "/#/phones/blah", PEOPLE_PHONES_ID); matcher.addURI("people", "/#/phones/#", PEOPLE_PHONES_ID); matcher.addURI("people", "/#/addresses", PEOPLE_ADDRESSES); matcher.addURI("people", "/#/addresses/#", PEOPLE_ADDRESSES_ID); matcher.addURI("people", "/#/contact-methods", PEOPLE_CONTACTMETH); matcher.addURI("people", "/#/contact-methods/#", PEOPLE_CONTACTMETH_ID); matcher.addURI("calls", "/", CALLS); matcher.addURI("calls", "/#", CALLS_ID); matcher.addURI("caller-id", "/", CALLERID); matcher.addURI("caller-id", "/*", CALLERID_TEXT); matcher.addURI("filter-recent", null, FILTERRECENT); matcher.addURI("auth", "/another/path/segment", ANOTHER_PATH_SEGMENT); checkAll(matcher); } private void checkAll(UriMatcher matcher) { private void checkAll(UriMatcher matcher) { check("content://asdf", UriMatcher.NO_MATCH, matcher); check("content://asdf", UriMatcher.NO_MATCH, matcher); check("content://people", PEOPLE, matcher); check("content://people", PEOPLE, matcher); check("content://people/", PEOPLE, matcher); check("content://people/1", PEOPLE_ID, matcher); check("content://people/1", PEOPLE_ID, matcher); check("content://people/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/2/phones", PEOPLE_PHONES, matcher); check("content://people/2/phones", PEOPLE_PHONES, matcher); Loading @@ -97,9 +119,11 @@ public class UriMatcherTest extends TestCase { check("content://people/2/contact-methods/3", PEOPLE_CONTACTMETH_ID, matcher); check("content://people/2/contact-methods/3", PEOPLE_CONTACTMETH_ID, matcher); check("content://people/2/contact-methods/asdf", UriMatcher.NO_MATCH, matcher); check("content://people/2/contact-methods/asdf", UriMatcher.NO_MATCH, matcher); check("content://calls", CALLS, matcher); check("content://calls", CALLS, matcher); check("content://calls/", CALLS, matcher); check("content://calls/1", CALLS_ID, matcher); check("content://calls/1", CALLS_ID, matcher); check("content://calls/asdf", UriMatcher.NO_MATCH, matcher); check("content://calls/asdf", UriMatcher.NO_MATCH, matcher); check("content://caller-id", CALLERID, matcher); check("content://caller-id", CALLERID, matcher); check("content://caller-id/", CALLERID, matcher); check("content://caller-id/asdf", CALLERID_TEXT, matcher); check("content://caller-id/asdf", CALLERID_TEXT, matcher); check("content://caller-id/1", CALLERID_TEXT, matcher); check("content://caller-id/1", CALLERID_TEXT, matcher); check("content://filter-recent", FILTERRECENT, matcher); check("content://filter-recent", FILTERRECENT, matcher); Loading