Skip to content

Commit

Permalink
task: [isExternalLinkImplied] Use explicit list of "internal" hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia committed Dec 30, 2024
1 parent 76e221f commit e6b54e0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/Link.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ export const isExternalLinkImplied = (targetUrl: string): boolean => {
const internalProtocols = ['mailto:'];
if (internalProtocols.includes(parsed.protocol)) return false;

// Any subdomain of consumerfinance.gov or the current host
const isInternalDomain =
parsed.host.endsWith('consumerfinance.gov') ||
parsed.host === window.location.host;
// [Internal] Any subdomain of consumerfinance.gov or the current host
const internalHosts = [
'www.consumerfinance.gov',
'sblhelp.consumerfinance.gov',
window.location.host,
];

return !isInternalDomain;
const isExternal = !internalHosts.includes(parsed.host);

return isExternal;
};

// External link icon w/ spacing
Expand Down

0 comments on commit e6b54e0

Please sign in to comment.