File tree Expand file tree Collapse file tree
search_engine/search/frontend/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,16 +6,17 @@ import axios from "axios";
66
77// Utility function to detect and render URLs as clickable links
88const renderMessageWithLinks = ( message ) => {
9- const urlRegex = / ( h t t p s ? : \/ \/ [ ^ \s \] \) , ] + ) / g;
9+ // Updated regex to exclude trailing parentheses unless balanced
10+ const urlRegex = / ( h t t p s ? : \/ \/ [ ^ \s \) \] ] * [ ^ \s \) \] \. ] ) / g;
1011 const parts = message . split ( urlRegex ) ;
11-
12+
1213 return parts . map ( ( part , index ) => {
1314 if ( urlRegex . test ( part ) ) {
1415 return (
15- < a
16+ < a
1617 key = { index }
17- href = { part }
18- target = "_blank"
18+ href = { part }
19+ target = "_blank"
1920 rel = "noopener noreferrer"
2021 style = { { color : "#007bff" , textDecoration : "underline" } }
2122 >
@@ -27,6 +28,7 @@ const renderMessageWithLinks = (message) => {
2728 } ) ;
2829} ;
2930
31+
3032const ChatbotWidget = ( ) => {
3133 const [ isOpen , setIsOpen ] = useState ( false ) ;
3234 const [ query , setQuery ] = useState ( "" ) ;
You can’t perform that action at this time.
0 commit comments