Fix for URISyntaxException with trailing spaces in the URL