From a909600117d18af97cc432a15a1fa3c67bc100de Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Sat, 14 Aug 2021 12:50:46 +1000 Subject: [PATCH] Comment on URL normalization --- src/main/java/org/jsoup/internal/StringUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jsoup/internal/StringUtil.java b/src/main/java/org/jsoup/internal/StringUtil.java index 7917f80433..f51fc2cfa9 100644 --- a/src/main/java/org/jsoup/internal/StringUtil.java +++ b/src/main/java/org/jsoup/internal/StringUtil.java @@ -288,8 +288,8 @@ public static URL resolve(URL base, String relUrl) throws MalformedURLException * @return an absolute URL if one was able to be generated, or the empty string if not */ public static String resolve(final String baseUrl, final String relUrl) { - URL base; try { + URL base; try { base = new URL(baseUrl); } catch (MalformedURLException e) { @@ -299,7 +299,8 @@ public static String resolve(final String baseUrl, final String relUrl) { } return resolve(base, relUrl).toExternalForm(); } catch (MalformedURLException e) { - // it may still be valid, just that Java doesn't have a registered stream handler for it, e.g. tel: + // it may still be valid, just that Java doesn't have a registered stream handler for it, e.g. tel + // we test here vs at start to normalize supported URLs (e.g. HTTP -> http) return validUriScheme.matcher(relUrl).find() ? relUrl : ""; } }