Skip to content

Commit

Permalink
fix: badge description with url (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncomerci committed Aug 23, 2023
1 parent d32f062 commit 8446de2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/User/Badges/BadgeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ interface Props {
}

function addNewLinesAfterFirstDot(text: string): string {
const dotIndex = text.indexOf('.')
const urlRegex = /https?:\/\/[^\s)]+/g

let dotIndex = text.indexOf('.')
let match: RegExpExecArray | null = null

while ((match = urlRegex.exec(text)) !== null) {
if (dotIndex > match.index && dotIndex < match.index + match[0].length) {
dotIndex = text.indexOf('.', match.index + match[0].length)
}
}

if (dotIndex === -1) return text

const firstPart = text.substring(0, dotIndex + 1)
Expand Down

0 comments on commit 8446de2

Please sign in to comment.