Skip to content

Commit 9db0fef

Browse files
committed
chore: fixes
1 parent 49b747e commit 9db0fef

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

openwisp_notifications/static/openwisp-notifications/js/notifications.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,16 @@ function notificationWidget($) {
208208
}
209209
klass = notificationReadStatus.get(elem.id);
210210

211+
// Used to convert absolute URLs in notification messages to relative paths
211212
function convertMessageWithRelativeURL(htmlString) {
212213
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');
215216
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);
220221
}
221222
});
222223
return doc.body.innerHTML;

0 commit comments

Comments
 (0)