File tree 1 file changed +7
-6
lines changed
openwisp_notifications/static/openwisp-notifications/js
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -208,15 +208,16 @@ function notificationWidget($) {
208
208
}
209
209
klass = notificationReadStatus . get ( elem . id ) ;
210
210
211
+ // Used to convert absolute URLs in notification messages to relative paths
211
212
function convertMessageWithRelativeURL ( htmlString ) {
212
213
const parser = new DOMParser ( ) ;
213
- const doc = parser . parseFromString ( htmlString , " text/html" ) ;
214
- const links = doc . querySelectorAll ( "a" ) ;
214
+ const doc = parser . parseFromString ( htmlString , ' text/html' ) ;
215
+ const links = doc . querySelectorAll ( 'a' ) ;
215
216
links . forEach ( ( link ) => {
216
- const absoluteUrl = link . getAttribute ( " href" ) ;
217
- if ( absoluteUrl ) {
218
- const url = new URL ( absoluteUrl ) ;
219
- link . setAttribute ( " href" , url . pathname ) ;
217
+ const url = link . getAttribute ( ' href' ) ;
218
+ if ( url ) {
219
+ const url = new URL ( url ) ;
220
+ link . setAttribute ( ' href' , url . pathname ) ;
220
221
}
221
222
} ) ;
222
223
return doc . body . innerHTML ;
You can’t perform that action at this time.
0 commit comments