public static boolean isValidRootUrl(String url) {
        UrlValidator validator = new CustomUrlValidator();
        return validator.isValid(url);
    }
@Test
    @Issue("JENKINS-31661")
    public void regularCases() {
        assertTrue(UrlHelper.isValidRootUrl("http://www.google.com"));
        // trailing slash is optional
        assertTrue(UrlHelper.isValidRootUrl("http://www.google.com/"));
        // path is allowed
        assertTrue(UrlHelper.isValidRootUrl("http://www.google.com/jenkins"));
        // port is allowed to be precised
        assertTrue(UrlHelper.isValidRootUrl("http://www.google.com:8080"));
        assertTrue(UrlHelper.isValidRootUrl("http://www.google.com:8080/jenkins"));
        // http or https are only valid schemes
        assertTrue(UrlHelper.isValidRootUrl("https://www.google.com:8080/jenkins"));
        // also with their UPPERCASE equivalent
        assertTrue(UrlHelper.isValidRootUrl("HTTP://www.google.com:8080/jenkins"));
        assertTrue(UrlHelper.isValidRootUrl("HTTPS://www.google.com:8080/jenkins"));

        assertTrue(UrlHelper.isValidRootUrl("http://localhost:8080/jenkins"));
        assertTrue(UrlHelper.isValidRootUrl("http://localhost:8080/jenkins/"));
        assertTrue(UrlHelper.isValidRootUrl("http://my_server:8080/jenkins"));
        assertTrue(UrlHelper.isValidRootUrl("http://MY_SERVER_IN_PRIVATE_NETWORK:8080/jenkins"));
        assertTrue(UrlHelper.isValidRootUrl("http://jenkins"));
        assertTrue(UrlHelper.isValidRootUrl("http://j"));
        assertTrue(UrlHelper.isValidRootUrl("http://j.io"));

        assertFalse(UrlHelper.isValidRootUrl("http://jenkins::"));
        assertFalse(UrlHelper.isValidRootUrl("http://jenkins::80"));
        // scheme must be correctly spelled (missing :)
        assertFalse(UrlHelper.isValidRootUrl("http//jenkins"));

        // scheme is mandatory
        assertFalse(UrlHelper.isValidRootUrl("com."));
        // spaces are forbidden
        assertFalse(UrlHelper.isValidRootUrl("http:// "));

        // examples not passing with a simple `new URL(url).toURI()` check
        assertFalse(UrlHelper.isValidRootUrl("http://jenkins//context"));
        assertFalse(UrlHelper.isValidRootUrl("http:/jenkins"));
        assertFalse(UrlHelper.isValidRootUrl("http://.com"));
        assertFalse(UrlHelper.isValidRootUrl("http:/:"));
        assertFalse(UrlHelper.isValidRootUrl("http://..."));
        assertFalse(UrlHelper.isValidRootUrl("http://::::@example.com"));
        assertFalse(UrlHelper.isValidRootUrl("ftp://jenkins"));
    }