-
-
Notifications
You must be signed in to change notification settings - Fork 8
GH-162 Make url's force clickable. #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new class was added to detect and make URLs clickable in chat messages by applying a special processor. This processor is now used when handling empty messages to ensure any links are recognized and can be clicked. Some unused import statements were also removed from another file, with no changes to the main logic. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
chatformatter-core/src/main/java/com/eternalcode/formatter/adventure/AdventureUrlPostProcessor.java (2)
12-12: Check the URL regex pattern for edge cases.The regex looks good for basic HTTP/HTTPS URLs, but it might miss some valid URLs or catch invalid ones. Consider testing with edge cases like URLs with ports, IP addresses, or special characters.
Consider using a more comprehensive URL pattern or a dedicated URL validation library for better accuracy:
-private static final Pattern URL_PATTERN = Pattern.compile("https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()!@:%_\\+.~#?&\\/\\/=]*)"); +private static final Pattern URL_PATTERN = Pattern.compile("https?://(?:[-\\w.])+(?:\\:[0-9]+)?(?:/(?:[\\w/_.])*(?:\\?(?:[&\\w\\[\\]%=.-])+)?(?:\\#(?:[\\w.-])+)?)?");
12-12: Consider improving the URL regex pattern.The current regex may not catch all valid URLs and could be simplified. Consider using a more comprehensive pattern or a dedicated URL validation library.
-private static final Pattern URL_PATTERN = Pattern.compile("https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()!@:%_\\+.~#?&\\/\\/=]*)"); +private static final Pattern URL_PATTERN = Pattern.compile("https?://(?:[-\\w.])+(?:[:\\d]+)?(?:/(?:[\\w/_.])*(?:\\?(?:[\\w&=%.])*)?(?:#(?:\\w)*)?)?)");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
chatformatter-core/src/main/java/com/eternalcode/formatter/ChatFormatterPlugin.java(0 hunks)chatformatter-core/src/main/java/com/eternalcode/formatter/ChatHandlerImpl.java(2 hunks)chatformatter-core/src/main/java/com/eternalcode/formatter/adventure/AdventureUrlPostProcessor.java(1 hunks)
💤 Files with no reviewable changes (1)
- chatformatter-core/src/main/java/com/eternalcode/formatter/ChatFormatterPlugin.java
🧰 Additional context used
🧬 Code Graph Analysis (1)
chatformatter-core/src/main/java/com/eternalcode/formatter/ChatHandlerImpl.java (1)
chatformatter-core/src/main/java/com/eternalcode/formatter/adventure/AdventureUrlPostProcessor.java (1)
AdventureUrlPostProcessor(10-23)
🔇 Additional comments (8)
chatformatter-core/src/main/java/com/eternalcode/formatter/adventure/AdventureUrlPostProcessor.java (4)
14-17: Good implementation of clickable URL configuration.The TextReplacementConfig setup looks clean and uses Adventure's built-in click event handling properly. This will make URLs clickable when clicked.
19-22: Simple and effective apply method.The implementation correctly applies the URL replacement to the component. Nice and straightforward approach.
14-17: Good implementation of clickable URL config.The TextReplacementConfig setup looks correct and will properly convert matched URLs into clickable components.
19-22: Simple and effective apply method.The implementation correctly applies the URL replacement to components.
chatformatter-core/src/main/java/com/eternalcode/formatter/ChatHandlerImpl.java (4)
3-3: Good import addition.The import is correctly placed and follows the existing import structure.
77-80: Smart integration of the URL processor.Adding the post-processor to EMPTY_MESSAGE_DESERIALIZER is the right approach since this handles player messages. URLs in chat messages will now be automatically clickable.
3-3: Clean import addition.The import is properly placed and follows the existing import structure.
77-80: Perfect integration point for URL processing.Adding the post-processor to EMPTY_MESSAGE_DESERIALIZER is the right approach since this deserializer handles user messages where URLs need to be made clickable.
No description provided.