Skip to content

Commit 8faef26

Browse files
authored
Fix archived reason markdown links rendering (#333)
## Description ✏️ Relates to SSWConsulting/SSW.Rules#2187 Fixes broken link rendering in archivedreason by removing unsafe URL regex replacement and correctly handling markdown-style links. ## Screenshot (optional) ✏️ Before: <img width="2211" height="1156" alt="image" src="https://github.com/user-attachments/assets/44c592a8-2889-454c-b6af-e45a63edcbab" /> After: <img width="2622" height="1300" alt="image" src="https://github.com/user-attachments/assets/42a81209-f663-4d33-bda6-2a0262a65b12" /> <!-- Check out the relevant rules - https://www.ssw.com.au/rules/use-pull-request-templates-to-communicate-expectations/ - https://www.ssw.com.au/rules/rules-to-better-pull-requests - https://www.ssw.com.au/rules/write-a-good-pull-request - https://www.ssw.com.au/rules/over-the-shoulder-prs - https://www.ssw.com.au/rules/do-you-use-co-creation-patterns -->
1 parent 719fe5f commit 8faef26

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/[filename]/ServerRulePage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ export default function ServerRulePage({ serverRulePageProps, tinaProps }: Serve
7373
<div
7474
className="text-sm text-ssw-red m-0"
7575
dangerouslySetInnerHTML={{
76-
__html: rule.archivedreason
77-
?.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" class="text-ssw-red underline hover:opacity-80">$1</a>')
78-
?.replace(/https?:\/\/[^\s]+/g, '<a href="$&" class="text-ssw-red underline hover:opacity-80">$&</a>'),
76+
__html: rule.archivedreason?.replace(
77+
/\[([^\]]+)\]\(([^)]+)\)/g,
78+
'<a href="$2" class="text-ssw-red underline hover:opacity-80" target="_blank" rel="noopener noreferrer">$1</a>'
79+
),
7980
}}
8081
/>
8182
</div>

0 commit comments

Comments
 (0)