public URLNormalizer removeTrailingSlash() {
        String urlRoot = HttpURL.getRoot(url);
        String path = toURL().getPath();
        String urlRootAndPath = urlRoot + path;

        if (path.endsWith("/")) {
            String newPath = StringUtils.removeEnd(path, "/");
            String newUrlRootAndPath = urlRoot + newPath;
            url = StringUtils.replaceOnce(
                    url, urlRootAndPath, newUrlRootAndPath);
        }
        return this;
    }
@Test
    public void testRemoveTrailingSlash() {
        s = "http://www.example.com/alice/";
        t = "http://www.example.com/alice";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/alice.html";
        t = "http://www.example.com/alice.html";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com";
        t = "http://www.example.com";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/blah/?param=value";
        t = "http://www.example.com/blah?param=value";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/blah?param=value";
        t = "http://www.example.com/blah?param=value";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/blah/#value";
        t = "http://www.example.com/blah#value";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/blah#value";
        t = "http://www.example.com/blah#value";
        assertEquals(t, n(s).removeTrailingSlash().toString());
        s = "http://www.example.com/";
        t = "http://www.example.com";
        assertEquals(t, n(s).removeTrailingSlash().toString());
    }