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 : ""; } }