Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOTE-2035 Exclude noreferrer from .gov links #784

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions web/themes/custom/votegov/src/js/external-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(() => {

// Enable external links behavior.
// `extlinkjs-ignore` attribute should be added to all icons in order to not render the uswds external links icon
// `extlinkjs-ignore` attribute should be added to all icons in order to not render the uswds external links icon
const externalLinks = document.querySelectorAll('a[href^="https"]:not([extlinkjs-ignore])');
const title_translated = Drupal.t('External link opens in new window');

Expand All @@ -15,7 +15,9 @@
externalLinks[i].classList.add('usa-link--external');
externalLinks[i].setAttribute('target', '_blank');
externalLinks[i].setAttribute('title', title_translated);
externalLinks[i].setAttribute('rel', 'noreferrer');
if (!new URL(externalLinks[i].href).hostname.endsWith(".gov")) {
externalLinks[i].setAttribute('rel', 'noreferrer');
}
}
}

Expand Down