Skip to content

Commit

Permalink
Fixed Hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
MeAlam1 committed Dec 10, 2024
1 parent 6115186 commit 9cbc581
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ public MutableComponent applyHyperlink(MutableComponent pComponent) {
String url = matcher.group(2).trim();
BaseLogger.log(BaseLogLevel.INFO, "Matched text: " + linkText + ", URL: " + url, true);

// Validate and apply hyperlink
if (MiscUtils.isValidURL(url)) {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://" + url;
}

MutableComponent hyperlink = Component.literal(linkText)
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0x1F5FE1))
.withUnderlined(true)
Expand All @@ -132,6 +135,7 @@ public MutableComponent applyHyperlink(MutableComponent pComponent) {
styledComponent.append(Component.literal(matcher.group(0)));
}


lastIndex = matcher.end();
}

Expand Down

0 comments on commit 9cbc581

Please sign in to comment.