Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: regex to replace url to a clickable link in notifictiaons #832

Merged
merged 2 commits into from
May 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/components/notifications/NotificationMenuEntry.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-alert text :color="alertColor" border="left">
<v-alert :class="`notification-menu-entry--priority-${entry.priority}`" text :color="alertColor" border="left">
<v-row align="start">
<v-col class="grow">
<div class="notification-menu-entry__headline mb-1 text-subtitle-1">
Expand All @@ -15,7 +15,9 @@
<span :class="`${alertColor}--text`">{{ entry.title }}</span>
</template>
</div>
<p class="text-body-2 mb-0 text--disabled font-weight-light" v-html="formatedText"></p>
<p
class="notification-menu-entry__description text-body-2 mb-0 text--disabled font-weight-light"
v-html="formatedText"></p>
</v-col>
<v-col
v-if="entry.priority !== 'critical'"
Expand Down Expand Up @@ -117,7 +119,10 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
declare readonly parentState: boolean

get formatedText() {
return this.entry.description.replace(/\[([^\]]+)\]\(([^)]+)\)/, '<a href="$2" target="_blank">$1</a>')
return this.entry.description.replace(
/(\bhttps?:\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gim,
'<a href="$1" target="_blank" class="' + this.alertColor + '--text">$1</a>'
)
}

get alertColor() {
Expand Down Expand Up @@ -153,4 +158,12 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
.notification-menu-entry__headline {
line-height: 1.2;
}

.notification-menu-entry__description {
max-width: 292px;
}

.notification-menu-entry--priority-critical .notification-menu-entry__description {
max-width: 336px;
}
</style>