Skip to content

Commit ce6f41a

Browse files
authored
Merge pull request #104 from NFDI4BIOIMAGE/chatbot_frontend_design_v0.8
fix the links who had ")" can not be used
2 parents a05474b + 113be83 commit ce6f41a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

search_engine/search/frontend/src/components/ChatbotWidget.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import axios from "axios";
66

77
// Utility function to detect and render URLs as clickable links
88
const renderMessageWithLinks = (message) => {
9-
const urlRegex = /(https?:\/\/[^\s\]\),]+)/g;
9+
// Updated regex to exclude trailing parentheses unless balanced
10+
const urlRegex = /(https?:\/\/[^\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+
3032
const ChatbotWidget = () => {
3133
const [isOpen, setIsOpen] = useState(false);
3234
const [query, setQuery] = useState("");

0 commit comments

Comments
 (0)