fix: nag link overflow

This commit is contained in:
tdgao
2026-08-31 12:42:02 -06:00
parent 17b81d1b5c
commit d3aa96e617
8 changed files with 51 additions and 17 deletions
@@ -75,7 +75,14 @@
/>
{{ getFormattedMessage(nag.title) }}
</span>
{{ getNagDescription(nag) }}
<span>
<span
v-for="(segment, index) in getNagDescriptionSegments(nag)"
:key="index"
:class="{ 'break-all': segment.isUrl }"
v-text="segment.text"
/>
</span>
<NuxtLink
v-if="nag.link && shouldShowLink(nag)"
:to="`/${project.project_type}/${project.slug ? project.slug : project.id}/${
@@ -439,6 +446,13 @@ function getNagDescription(nag: Nag): string {
return formatMessage(nag.description)
}
function getNagDescriptionSegments(nag: Nag): { text: string; isUrl: boolean }[] {
return getNagDescription(nag)
.split(/(https?:\/\/[^\s"'<>“”]+)/gi)
.filter(Boolean)
.map((text) => ({ text, isUrl: /^https?:\/\//i.test(text) }))
}
function getFormattedMessage(message: string | MessageDescriptor): string {
if (typeof message === 'string') {
return message