public URLNormalizer removeDirectoryIndex() {
        String path = toURL().getPath();
        if (PATTERN_PATH_LAST_SEGMENT.matcher(path).matches()) {
            url = StringUtils.replaceOnce(
                    url, path, StringUtils.substringBeforeLast(path, "/") + "/");
        }
        return this;
    }
@Test
    public void testRemoveDirectoryIndex() {
        s = "http://www.example.com/index.html";
        t = "http://www.example.com/";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
        s = "http://www.example.com/index.html/a";
        t = "http://www.example.com/index.html/a";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
        s = "http://www.example.com/a/Default.asp";
        t = "http://www.example.com/a/";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
        s = "http://www.example.com/a/index.php?a=b&c=d";
        t = "http://www.example.com/a/?a=b&c=d";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
        s = "http://www.example.com/a/z.php?a=b&c=d/index.htm";
        t = "http://www.example.com/a/z.php?a=b&c=d/index.htm";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
        s = "http://www.example.com/index,html";
        t = "http://www.example.com/index,html";
        assertEquals(t, n(s).removeDirectoryIndex().toString());
    }