TurbolinksHelper { static String encodeUrl(String originalUrl) { try { URL newUrl = new URL(originalUrl); URI uri = new URI(newUrl.getProtocol(), newUrl.getUserInfo(), newUrl.getHost(), newUrl.getPort(), newUrl.getPath(), newUrl.getQuery(), newUrl.getRef()); return uri.toURL().toString(); } catch (Exception e) { return null; } }    }
@Test public void encodeUrlProperlyEncodes() { String url = "http: assertThat(TurbolinksHelper.encodeUrl(url)).doesNotContain(" "); }