mirror of
https://github.com/modrinth/code.git
synced 2026-09-05 06:19:11 +00:00
fix: nag link overflow
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user