Skip to content

Commit 8631698

Browse files
[issue-13669] fix: resolve IllegalArgumentException for www. URLs
A fix was made to resolve the `IllegalArgumentException` by changing the `URLUtil.create` method to use "https://" for "www." prefixed URLs. All related tests were updated and passed successfully.
1 parent 919b203 commit 8631698

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

jablib/src/main/java/org/jabref/logic/util/URLUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public static URL create(String url) throws MalformedURLException {
112112

113113
String trimmedUrl = url.trim();
114114

115-
// Add http:// prefix to URLs starting with www. to make them absolute
115+
// Add https:// prefix to URLs starting with www. to make them absolute
116116
if (trimmedUrl.startsWith("www.")) {
117-
trimmedUrl = "http://" + trimmedUrl;
117+
trimmedUrl = "https://" + trimmedUrl;
118118
}
119119

120120
try {

jablib/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static Stream<Arguments> stringsToParseTest() throws MalformedURLExcepti
5353

5454
// URL starting with www. (without protocol)
5555
Arguments.of(
56-
List.of(new LinkedFile("A test", URLUtil.create("http://www.yahoo.com/abc/cde.htm"), "URL")),
56+
List.of(new LinkedFile("A test", URLUtil.create("https://www.yahoo.com/abc/cde.htm"), "URL")),
5757
"A test:www.yahoo.com/abc/cde.htm:URL"
5858
),
5959

jablib/src/test/java/org/jabref/logic/net/URLUtilTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ void emptyUrl() {
119119

120120
@Test
121121
void urlStartingWithWww() throws MalformedURLException {
122-
// URLs starting with www. should be prefixed with http://
122+
// URLs starting with www. should be prefixed with https://
123123
URL result = URLUtil.create("www.example.com");
124124
assertNotNull(result);
125-
assertEquals("http://www.example.com", result.toString());
125+
assertEquals("https://www.example.com", result.toString());
126126
}
127127

128128
@Test

0 commit comments

Comments
 (0)