diff --git a/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 b/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 index e811937e..b8e98318 100644 --- a/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 +++ b/roles/srv-web-7-7-inj-logout/templates/logout.js.j2 @@ -14,9 +14,16 @@ return str && /(?:^|\W)log\s*out(?:\W|$)|logout/i.test(str); } - function hasLogoutAttribute(el) { - for (const attr of el.attributes) { - if (/logout/i.test(attr.name) || /\/logout/i.test(attr.value)) { + /** + * Returns true if any attribute name or value on the given element + * contains the substring "logout" (case-insensitive). + * + * @param {Element} element – The DOM element to inspect. + * @returns {boolean} – True if "logout" appears in any attribute name or value. + */ + function containsLogoutAttribute(element) { + for (const attribute of element.attributes) { + if (/logout/i.test(attribute.name) || /logout/i.test(attribute.value)) { return true; } } @@ -43,23 +50,41 @@ return false; } - function overrideLogout(el) { + /** + * Apply logout redirect behavior to a matching element: + * – Installs a capturing click‐handler to force navigation to logoutUrl + * – Always sets href/formaction/action to logoutUrl + * – Marks the element as patched to avoid double‐binding + * + * @param {Element} el – The element to override (e.g. ,