Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaySagar-Git committed Nov 18, 2024
1 parent 1952514 commit b75bc8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/components/Common/MarkdownPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,26 @@ const MarkdownPreview = ({
title?: string | null;
text: string;
}) {
try {
const url = new URL(href);
if (!["http:", "https:"].includes(url.protocol)) {
return text;
}
href = url.toString();
} catch {
return text;
}
return `<a href="${href}" target="_blank" rel="noopener noreferrer" title="${
title || ""
}">${text}</a>`;
};

const processedMarkdown = markdown
.replace(/@(\w+)/g, (_, username) => {
.replace(/@([a-zA-Z0-9_]{3,30})/g, (_, username) => {
const user = MentionedUsers[username];
if (user) {
return `<span class="mention cursor-pointer font-medium text-primary hover:underline" data-username="${username}">@${username}</span>`;
const sanitizedUsername = username.replace(/[<>"'&]/g, "");
return `<span class="mention cursor-pointer font-medium text-primary hover:underline" data-username="${sanitizedUsername}">@${sanitizedUsername}</span>`;
} else {
return `@${username}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Facility/DoctorNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

interface DoctorNoteProps {
state: PatientNoteStateType;
setReload: any;
setReload?: (value: boolean) => void;
handleNext: () => void;
disableEdit?: boolean;
setReplyTo?: (reply_to: PatientNotesModel | undefined) => void;
Expand Down

0 comments on commit b75bc8b

Please sign in to comment.