From 985f1fe13aa0b1d37c6f6f17a948fc240a03dcef Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Sun, 14 Aug 2022 19:08:50 +1000 Subject: [PATCH] Include help link for malformed URLs Try to hint people to use absUrl() --- src/main/java/org/jsoup/helper/HttpConnection.java | 2 +- src/test/java/org/jsoup/helper/HttpConnectionTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jsoup/helper/HttpConnection.java b/src/main/java/org/jsoup/helper/HttpConnection.java index 9cc6bc1414..6b856fe68e 100644 --- a/src/main/java/org/jsoup/helper/HttpConnection.java +++ b/src/main/java/org/jsoup/helper/HttpConnection.java @@ -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; } diff --git a/src/test/java/org/jsoup/helper/HttpConnectionTest.java b/src/test/java/org/jsoup/helper/HttpConnectionTest.java index 4bd7dfb502..1fe5181509 100644 --- a/src/test/java/org/jsoup/helper/HttpConnectionTest.java +++ b/src/test/java/org/jsoup/helper/HttpConnectionTest.java @@ -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); }