Urls { public static String getBasename(String url) { if (url==null) return null; if (getProtocol(url)!=null) { int firstQ = url.indexOf('?'); if (firstQ>=0) url = url.substring(0, firstQ); } url = Strings.removeAllFromEnd(url, "/"); return url.substring(url.lastIndexOf('/')+1); }  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 testGetBasename() { assertEquals(Urls.getBasename("http: assertEquals(Urls.getBasename("http: assertEquals(Urls.getBasename("http: assertEquals(Urls.getBasename("filewith?.txt"), "filewith?.txt"); assertEquals(Urls.getBasename(""), ""); assertEquals(Urls.getBasename(null), null); }