Urls { public static boolean isUrlWithProtocol(String x) { return isUrlWithProtocol(x, true, false); }  static Function<String,URI> stringToUriFunction(); static Function<String,URL> stringToUrlFunction(); static final URL toUrl(@Nullable String url); static final URL toUrl(@Nullable URI uri); static final URI toUri(@Nullable String uri); static final URI toUri(@Nullable URL url); static boolean isUrlWithProtocol(String x); static boolean isUrlWithProtocol(String x, boolean allowSpacesAfterCharAfterColon, boolean allowMultiline); static String mergePaths(String ...items); static String encode(String text); static String decode(String text); static String getProtocol(String url); static String getBasename(String url); static boolean isDirectory(String fileUrl); static File toFile(String fileUrl); static String asDataUrlBase64(String data); static String asDataUrlBase64(MediaType type, byte[] bytes);  }
@Test public void testIsUrlWithProtocol() { Assert.assertTrue(Urls.isUrlWithProtocol("a1+b.c-d:/")); Assert.assertTrue(Urls.isUrlWithProtocol("http: Assert.assertTrue(Urls.isUrlWithProtocol("protocol:xxx")); Assert.assertFalse(Urls.isUrlWithProtocol("protocol")); Assert.assertFalse(Urls.isUrlWithProtocol(":/")); Assert.assertFalse(Urls.isUrlWithProtocol("1:/")); Assert.assertTrue(Urls.isUrlWithProtocol("a1+b.c-:those/chars/are/allowed/in/protocol")); Assert.assertFalse(Urls.isUrlWithProtocol(null)); Assert.assertTrue(Urls.isUrlWithProtocol("protocol:we allow spaces and %13 percent chars")); Assert.assertFalse(Urls.isUrlWithProtocol("protocol:we allow spaces\nbut not new lines")); Assert.assertFalse(Urls.isUrlWithProtocol("protocol: no space immediately after colon though")); Assert.assertFalse(Urls.isUrlWithProtocol("protocol:")); Assert.assertFalse(Urls.isUrlWithProtocol("protocol_underscore_disallowed:")); }