UrlEncoder { public String encode(final String s, final Charset charset) { return encode(s, charset.name()); } protected  UrlEncoder(final Type type); String encode(final String s, final Charset charset); String encode(final String unsafeInput, final String charsetName); static final UrlEncoder QUERY_INSTANCE; static final UrlEncoder PATH_INSTANCE; static final UrlEncoder FULL_PATH_INSTANCE; }
@Test public void encodeApostrophe() { assertEquals("someone%27s%20bad%20url", UrlEncoder.FULL_PATH_INSTANCE.encode("someone's bad url", CharEncoding.UTF_8)); }
@Test public void dontEncodeSemicolon() { String encoded = UrlEncoder.PATH_INSTANCE.encode("path;jsessionid=1234567890", CharEncoding.UTF_8); assertEquals("path;jsessionid=1234567890", encoded); }
@Test public void dontStopOnNullByte() throws Exception { assertEquals("someone%27s%20badNULL%20url", UrlEncoder.FULL_PATH_INSTANCE.encode("someone's bad\0 url", CharEncoding.UTF_8)); }