@@ -197,6 +197,7 @@ function notificationWidget($) {
197
197
function notificationListItem ( elem ) {
198
198
let klass ,
199
199
datetime = dateTimeStampToDateTimeLocaleString ( new Date ( elem . timestamp ) ) ;
200
+ const target_url = new URL ( elem . target_url ) ;
200
201
201
202
if ( ! notificationReadStatus . has ( elem . id ) ) {
202
203
if ( elem . unread ) {
@@ -207,8 +208,22 @@ function notificationWidget($) {
207
208
}
208
209
klass = notificationReadStatus . get ( elem . id ) ;
209
210
211
+ function convertMessageWithRelativeURL ( htmlString ) {
212
+ const parser = new DOMParser ( ) ;
213
+ const doc = parser . parseFromString ( htmlString , "text/html" ) ;
214
+ const links = doc . querySelectorAll ( "a" ) ;
215
+ links . forEach ( ( link ) => {
216
+ const absoluteUrl = link . getAttribute ( "href" ) ;
217
+ if ( absoluteUrl ) {
218
+ const url = new URL ( absoluteUrl ) ;
219
+ link . setAttribute ( "href" , url . pathname ) ;
220
+ }
221
+ } ) ;
222
+ return doc . body . innerHTML ;
223
+ }
224
+
210
225
return `<div class="ow-notification-elem ${ klass } " id=ow-${ elem . id }
211
- data-location="${ elem . target_url } " role="link" tabindex="0">
226
+ data-location="${ target_url . pathname } " role="link" tabindex="0">
212
227
<div class="ow-notification-inner">
213
228
<div class="ow-notification-meta">
214
229
<div class="ow-notification-level-wrapper">
@@ -217,7 +232,7 @@ function notificationWidget($) {
217
232
</div>
218
233
<div class="ow-notification-date">${ datetime } </div>
219
234
</div>
220
- ${ elem . message }
235
+ ${ convertMessageWithRelativeURL ( elem . message ) }
221
236
</div>
222
237
</div>` ;
223
238
}
0 commit comments