Skip to content

Commit

Permalink
Test url paths are handled as-is
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Sep 9, 2023
1 parent 04ee552 commit 4e7ea39
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/java/org/jsoup/helper/HttpConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ public void caseInsensitiveHeaders(Locale locale) {
assertEquals("https://test.com/foo%20bar/%5BOne%5D?q=white+space#frag%20ment", url3.toExternalForm());
}

@Test void urlPathIsPreservedDoesntDoubleEncode() throws MalformedURLException {
URL url1 = new URL("https://test.com/[foo] bar+/%5BOne%5D?q=white space#frag ment");
URL url2 = new UrlBuilder(url1).build();
URL url3 = new UrlBuilder(url2).build();
assertEquals("https://test.com/[foo]%20bar+/%5BOne%5D?q=white+space#frag%20ment", url2.toExternalForm());
assertEquals("https://test.com/[foo]%20bar+/%5BOne%5D?q=white+space#frag%20ment", url3.toExternalForm());
}

@Test void connectToEncodedUrl() {
Connection connect = Jsoup.connect("https://example.com/a%20b%20c?query+string");
URL url = connect.request().url();
Expand Down

0 comments on commit 4e7ea39

Please sign in to comment.