Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

feat: Link decoration for single labeled and whitelisted internal hosts.

Open Barrylimarti opened this issue 5 months ago • 7 comments

Proposed changes (including videos or screenshots)

Links like http://server/document were not decorated in the chat even if the user whitelisted the domain name as "server". Screenshot 2024-09-09 at 3 21 17 AM Screenshot 2024-09-09 at 3 20 45 AM

It needed to be parsed as a link to get decorated, hence the message-parser required to be modified to adapt to this change. I traced the point of change to be the grammar.pegjs file, specifically where the domain was verified and then the text was passed to autolink function to get parsed as a 'LINK' and not as a 'PLAIN_TEXT'. Screenshot 2024-09-09 at 3 14 34 AM

I created a utility function to verify the domain names from the custom whitelist for which the text needed to be parsed as a link and then used that function in the pegjs file to verify the domain name. To check this behaviour, I created a test case also. Screenshot 2024-09-09 at 3 21 23 AM

Issue(s)

This PR may close #29874

Steps to test or reproduce

Mentioned in the issue tagged above.

Further comments

It was first time for me working on a pegjs file, hence I am not sure about the code quality. Please feel free to reach out if any changes or modification is required.

Barrylimarti avatar Sep 08 '24 22:09 Barrylimarti