public URLNormalizer removeSessionIds() {
        if (StringUtils.containsIgnoreCase(url, ";jsessionid=")) {
            url = url.replaceFirst(
                    "(;jsessionid=([A-F0-9]+)((\\.\\w+)*))", "");
        } else {
            String u = StringUtils.substringBefore(url, "?");
            String q = StringUtils.substringAfter(url, "?");
            if (StringUtils.containsIgnoreCase(url, "PHPSESSID=")) {
                q = q.replaceFirst("(&|^)(PHPSESSID=[0-9a-zA-Z]*)", "");
            } else if (StringUtils.containsIgnoreCase(url, "ASPSESSIONID")) {
                q = q.replaceFirst(
                        "(&|^)(ASPSESSIONID[a-zA-Z]{8}=[a-zA-Z]*)", "");
            }
            if (!StringUtils.isBlank(q)) {
                u += "?" + StringUtils.removeStart(q, "&");
            }
            url = u;
        }
        return this;
    }
@Test
    public void testRemoveSessionIds() {
        //PHP
        s = "http://1.eg.com/app?a=b&PHPSESSID=f9f2770d591366bc&aa=bbb&c=d";
        t = "http://1.eg.com/app?a=b&aa=bbb&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://2.eg.com/app?PHPSESSID=f9f2770d591366bc&aaa=bbb&c=d";
        t = "http://2.eg.com/app?aaa=bbb&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://3.eg.com/app?a=b&PHPSESSID=f9f2770d591366bc";
        t = "http://3.eg.com/app?a=b";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://4.eg.com/app?a=b&c=d&NOPHPSESSID=f9f2770d591366bc&a=b";
        t = "http://4.eg.com/app?a=b&c=d&NOPHPSESSID=f9f2770d591366bc&a=b";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://5.eg.com/app?PHPSESSID=f9f2770d591366bc";
        t = "http://5.eg.com/app";
        assertEquals(t, n(s).removeSessionIds().toString());

        //Java EE
        s = "http://6.eg.com/app;jsessionid=1E6FEC03D29ED?a=b&c=d";
        t = "http://6.eg.com/app?a=b&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://7.eg.com/app;jsessionid=1E6FEC03D29ED";
        t = "http://7.eg.com/app";
        assertEquals(t, n(s).removeSessionIds().toString());

        //https://github.com/Norconex/collector-http/issues/311
        s = "http://myurl.com;jsessionid="
                + "E460A97852FA769CD9AD387095C680A9.tpdila09v_2?p=v";
        t = "http://myurl.com?p=v";
        assertEquals(t, n(s).removeSessionIds().toString());

        //ASP
        s = "http://8.eg.com/app?y=z&ASPSESSIONIDSCQCTTCT=CMHFECGKC&a=b&c=d";
        t = "http://8.eg.com/app?y=z&a=b&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://9.eg.com/app?ASPSESSIONIDSCQCTTCT=CMHFECGKC&a=b&c=d";
        t = "http://9.eg.com/app?a=b&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://10.eg.com/app?a=b&ASPSESSIONIDSCQCTTCT=CMHFECGKC";
        t = "http://10.eg.com/app?a=b";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://11.eg.com/app?a=b&NOASPSESSIONIDSCQCTTCT=CMHFECGKC&c=d";
        t = "http://11.eg.com/app?a=b&NOASPSESSIONIDSCQCTTCT=CMHFECGKC&c=d";
        assertEquals(t, n(s).removeSessionIds().toString());
        s = "http://12.eg.com/app?ASPSESSIONIDSCQCTTCT=CMHFECGKC";
        t = "http://12.eg.com/app";
        assertEquals(t, n(s).removeSessionIds().toString());
    }