2929 * It is intentionally stateless and uses asynchronous HTTP requests to avoid blocking calling
3030 * threads.
3131 */
32-
3332public class LinkDetection {
3433 private static final HttpClient HTTP_CLIENT = HttpClient .newHttpClient ();
3534
@@ -40,7 +39,6 @@ public class LinkDetection {
4039 * Links to intentionally ignore in order to reduce false positives when scanning chat messages
4140 * or source-code snippets.
4241 */
43-
4442 private static final Set <LinkFilter > DEFAULT_FILTERS =
4543 Set .of (LinkFilter .SUPPRESSED , LinkFilter .NON_HTTP_SCHEME );
4644
@@ -89,7 +87,6 @@ private LinkDetection() {
8987 * @param filter a set of filters controlling which detected links are returned
9088 * @return a list of extracted links in the order they appear in the text
9189 */
92-
9390 public static List <String > extractLinks (String content , Set <LinkFilter > filter ) {
9491 return new UrlDetector (content , UrlDetectorOptions .BRACKET_MATCH ).detect ()
9592 .stream ()
@@ -121,7 +118,6 @@ public static List<String> extractLinks(String content) {
121118 * @param content the text to scan
122119 * @return {@code true} if at least one URL-like pattern is detected
123120 */
124-
125121 public static boolean containsLink (String content ) {
126122 return !(new UrlDetector (content , UrlDetectorOptions .BRACKET_MATCH ).detect ().isEmpty ());
127123 }
@@ -145,7 +141,6 @@ public static boolean containsLink(String content) {
145141 * @return a {@code CompletableFuture} completing with {@code true} if the link is broken,
146142 * {@code false} otherwise
147143 */
148-
149144 public static CompletableFuture <Boolean > isLinkBroken (String url ) {
150145 // Try HEAD request first (cheap and fast)
151146 HttpRequest headRequest = HttpRequest .newBuilder (URI .create (url ))
@@ -210,7 +205,6 @@ public static CompletableFuture<Boolean> isLinkBroken(String url) {
210205 * @return a {@code CompletableFuture} that completes with the modified text, or the original
211206 * text if no broken links were found
212207 */
213-
214208 public static CompletableFuture <String > replaceBrokenLinks (String text , String replacement ) {
215209 List <String > links = extractLinks (text , DEFAULT_FILTERS );
216210
@@ -254,7 +248,6 @@ private static String replaceLinks(List<String> linksToReplace, String text,
254248 * @return an {@link Optional} containing the normalized link, or {@code Optional.empty()} if
255249 * the link should be filtered out
256250 */
257-
258251 private static Optional <String > toLink (Url url , Set <LinkFilter > filter ) {
259252 String raw = url .getOriginalUrl ();
260253 if (filter .contains (LinkFilter .SUPPRESSED ) && raw .contains (">" )) {
0 commit comments