Skip to content

Commit

Permalink
Include help link for malformed URLs
Browse files Browse the repository at this point in the history
Try to hint people to use absUrl()
  • Loading branch information
jhy committed Aug 14, 2022
1 parent 6b67d05 commit 985f1fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Connection url(String url) {
try {
req.url(new URL(encodeUrl(url)));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(String.format("The supplied URL, '%s', is malformed. Make sure it is an absolute URL, and starts with 'http://' or 'https://'.", url), e);
throw new IllegalArgumentException(String.format("The supplied URL, '%s', is malformed. Make sure it is an absolute URL, and starts with 'http://' or 'https://'. See https://jsoup.org/cookbook/extracting-data/working-with-urls", url), e);
}
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jsoup/helper/HttpConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void caseInsensitiveHeaders(Locale locale) {
Jsoup.connect("jsoup.org/test");
} catch (IllegalArgumentException e) {
threw = true;
assertEquals("The supplied URL, 'jsoup.org/test', is malformed. Make sure it is an absolute URL, and starts with 'http://' or 'https://'.", e.getMessage());
assertEquals("The supplied URL, 'jsoup.org/test', is malformed. Make sure it is an absolute URL, and starts with 'http://' or 'https://'. See https://jsoup.org/cookbook/extracting-data/working-with-urls", e.getMessage());
}
assertTrue(threw);
}
Expand Down

0 comments on commit 985f1fe

Please sign in to comment.