From 8a3e14b4200da775e9a17ad6037988fb30c37f17 Mon Sep 17 00:00:00 2001 From: Mark McPherson Date: Wed, 11 Sep 2024 11:39:34 +0100 Subject: [PATCH] Check class attr exists before using in match --- inst/app/www/js/custom.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/app/www/js/custom.js b/inst/app/www/js/custom.js index 3e6e777c..873a8252 100644 --- a/inst/app/www/js/custom.js +++ b/inst/app/www/js/custom.js @@ -10,14 +10,15 @@ $(document).ready(function () { // Current link var a = $(this); // If no href attribute, exit early (internal links will not have href) - if (!$(this).attr("href")) return; + if (!a.attr("href")) return; if ( !a.attr('href').match(/^mailto\:/) // Email links && (a[0].hostname != window.location.hostname) // Internal links && !a.attr('href').match(/^javascript\:/) // Starting javascript && !a.attr('href').match(/^$/) // Empty links && !a.attr('href').match(/^#maincontent$/) // Skip link - && !a.attr('class').match(/^nhsuk-header__link$/) // NHSBSA header icon + && !(a.attr('class') && // NHSBSA header icon + a.attr('class').match(/^nhsuk-header__link$/)) ) { // Append space then icon to link a.after(' ');