UriUtil { public static Optional<String> getLastSegment(final URI uri) { return getSegment(uri, -1); } private  UriUtil(); static URI toUri(final String s); static boolean isFileUri(final URI uri); static Optional<String> getLastSegment(final URI uri); static String getLastSegmentOrHost(final URI uri); static String getParent(final URI uri); static String getPath(final URI uri);  }
@Test public void test_getLastSegment() throws Exception { assertThat(getLastSegment(HTTP_URI), equalTo(Optional.<String> absent())); assertThat(getLastSegment(HTTP_WITH_PATH_URI), equalTo(Optional.of("here"))); assertThat(getLastSegment(HTTPS_URI), equalTo(Optional.<String> absent())); assertThat(getLastSegment(FILE_ABS_URI), equalTo(Optional.of("asd"))); assertThat(getLastSegment(FILE_REL_URI), equalTo(Optional.of("qweasd"))); }
@Test public void test_getLastSegment_uri_with_eval() throws Exception { final URI uri = URI.create("http: assertThat(getLastSegment(uri), equalTo(Optional.of("dojo.js#222(Function)%231(eval)(7)"))); }