Skip to content

Instantly share code, notes, and snippets.

Created Aug 21, 2020
What would you like to do?
Java URI copy constructor

Using the URI copy constructor on an URI where the userinfo part contains a percent-escaped colon (U+003A as %3A) produces a different result.

import org.junit.Assert;
import org.junit.jupiter.api.Test;
public class URITest {
void test() throws URISyntaxException {
URI u = new URI("");
URI copy = new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), u.getPath(), u.getQuery(), u.getFragment());
Assert.assertEquals(u, copy);
// java.lang.AssertionError: expected:<> but was:<>
// Expected :
// Actual :
Copy link

simon04 commented Aug 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment