@ SneakyThrows public static URI ensureTrailingSlash ( URI uri ) { URIBuilder builder = new URIBuilder ( uri ) ; if ( ! builder . getPath ( ) . endsWith ( "/" ) ) { builder . setPath ( builder . getPath ( ) + "/" ) ; } return builder . build ( ) ; }
Adds a trailing slash to the URI if it does not already have one .