Skip to content

Commit 675d2c4

Browse files
committed
Address PR Comments
1 parent 3208a83 commit 675d2c4

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/AutolinkExtension.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ public Builder linkTypes(AutolinkType... linkTypes) {
6060
throw new NullPointerException("linkTypes must not be null");
6161
}
6262

63-
if (linkTypes.length == 0) {
64-
throw new IllegalArgumentException("linkTypes must not be empty");
65-
}
66-
6763
return this.linkTypes(Set.of(linkTypes));
6864
}
6965

commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/AutolinkType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.commonmark.ext.autolink;
22

3+
/**
4+
* The types of strings that can be automatically turned into links.
5+
*/
36
public enum AutolinkType {
47
/**
58
* URL such as {@code http://example.com}

commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/internal/AutolinkPostProcessor.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ public class AutolinkPostProcessor implements PostProcessor {
1414

1515
private final LinkExtractor linkExtractor;
1616

17-
public AutolinkPostProcessor() {
18-
this(EnumSet.of(AutolinkType.URL, AutolinkType.EMAIL));
19-
}
20-
2117
public AutolinkPostProcessor(Set<AutolinkType> linkTypes) {
2218
if (linkTypes == null) {
2319
throw new NullPointerException("linkTypes must not be null");
@@ -27,7 +23,7 @@ public AutolinkPostProcessor(Set<AutolinkType> linkTypes) {
2723
throw new IllegalArgumentException("linkTypes must not be empty");
2824
}
2925

30-
EnumSet<LinkType> types = EnumSet.noneOf(LinkType.class);
26+
var types = EnumSet.noneOf(LinkType.class);
3127
for (AutolinkType linkType : linkTypes) {
3228
switch (linkType) {
3329
case URL:
@@ -99,12 +95,12 @@ private static Text createTextNode(String literal, Span span, SourceSpan sourceS
9995
}
10096

10197
private static String getDestination(LinkSpan linkSpan, String linkText) {
102-
LinkType type = linkSpan.getType();
98+
var type = linkSpan.getType();
10399

104100
if (type == LinkType.EMAIL) {
105101
return "mailto:" + linkText;
106102
} else if (type == LinkType.WWW) {
107-
return "http://" + linkText;
103+
return "https://" + linkText;
108104
} else {
109105
return linkText;
110106
}

commonmark-ext-autolink/src/test/java/org/commonmark/ext/autolink/AutolinkTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void wwwLinksDontWorkByDefault() {
7272
@Test
7373
public void wwwLinks() {
7474
String html = WWW_RENDERER.render(WWW_PARSER.parse("www.example.com"));
75-
assertThat(html).isEqualTo("<p><a href=\"http://www.example.com\">www.example.com</a></p>\n");
75+
assertThat(html).isEqualTo("<p><a href=\"https://www.example.com\">www.example.com</a></p>\n");
7676
}
7777

7878
@Test

0 commit comments

Comments
 (0)