Skip to content

Commit

Permalink
Check class attr exists before using in match
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMc1089 committed Sep 11, 2024
1 parent 5b00cc6 commit 8a3e14b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions inst/app/www/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('&nbsp;<i class="fa-solid fa-arrow-up-right-from-square"></i>');
Expand Down

0 comments on commit 8a3e14b

Please sign in to comment.