Skip to content

Commit 55b3bbd

Browse files
committed
fix: improve URL regex to preserve bracketed URLs
Makes URL processing more conservative and respectful of existing formatting.
1 parent ef15a97 commit 55b3bbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/getProcessedText.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const getProcessedText = (text) => {
99
}
1010

1111
// Regex to match URLs that are NOT already in markdown or HTML link format
12-
// This looks for URLs that are not preceded by ]( or href=" and not followed by )
13-
const urlRegex = /(?<!\]\(|href=["'])https?:\/\/[^\s\[\]()]+(?![)\]])/gi;
12+
// This looks for URLs that are not preceded by ]( or href=" or [ and not followed by ) or ]
13+
const urlRegex = /(?<!\]\(|href=["']|\[)https?:\/\/[^\s\[\]()]+(?![)\]])/gi;
1414

1515
// Replace bare URLs with markdown links
1616
const processedText = text.replace(urlRegex, (url) => {

0 commit comments

Comments
 (0)