diff --git a/docs/utils.md b/docs/utils.md index 1793de9c9..7ee969274 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -5,13 +5,13 @@ _Hide Visually_ how to use in your styled component `export const Component = styled.span'${hideVisually};';` -_whiteListed_ +_allowListed_ -`import { whiteListed } from '@comicrelief/component-library';` +`import { allowListed } from '@comicrelief/component-library';` -`whiteListed(url)` +`allowListed(url)` -Check if a url is whiteListed. Used to check links and change link target. +Check if a url is allowListed. Used to check links and change link target. _Z Index_ diff --git a/src/components/Atoms/Link/Link.js b/src/components/Atoms/Link/Link.js index 20d7ebf49..564648656 100755 --- a/src/components/Atoms/Link/Link.js +++ b/src/components/Atoms/Link/Link.js @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import StyledLink, { HelperText, IconWrapper } from './Link.style'; -import whiteListed from '../../../utils/whiteListed'; +import allowListed from '../../../utils/allowListed'; import { getDomain } from '../../../utils/internalLinkHelper'; let window = ''; @@ -22,7 +22,7 @@ const Link = ({ const [documentHost, setDocumentHost] = useState(''); /** * If we haven't specifically set the target via props, check if - * this is an internal link OR on our whitelist before making it a '_self' link + * this is an internal link OR on our allowList before making it a '_self' link */ if (target === null) { // Use our helper function to determine the raw domains to compare @@ -30,7 +30,7 @@ const Link = ({ const linkDomain = getDomain(href); // Additional check for applications that need more control - const isWhiteListOverridden = rest.overrideWhiteList === true; + const isallowListOverridden = rest.overrideallowList === true; /** * If the link has no domain supplied (likely '/' or '#') @@ -38,9 +38,9 @@ const Link = ({ * in a new tab */ const isExternalLink = linkDomain !== '' && (currentDomain !== linkDomain); - const isWhiteListed = whiteListed(href); + const isallowListed = allowListed(href); - window = isExternalLink && (isWhiteListOverridden || !isWhiteListed) ? '_blank' : '_self'; + window = isExternalLink && (isallowListOverridden || !isallowListed) ? '_blank' : '_self'; } else { window = target === 'blank' ? '_blank' : '_self'; } diff --git a/src/components/Organisms/Footer/Footer.js b/src/components/Organisms/Footer/Footer.js index ff088ff42..37b62c2e7 100644 --- a/src/components/Organisms/Footer/Footer.js +++ b/src/components/Organisms/Footer/Footer.js @@ -52,7 +52,7 @@ Footer.propTypes = { navItems: PropTypes.objectOf(PropTypes.shape), footerCopy: PropTypes.string, campaign: PropTypes.string, - overrideWhiteList: PropTypes.bool, + overrideallowList: PropTypes.bool, additionalLegalLine: PropTypes.string }; @@ -60,7 +60,7 @@ Footer.defaultProps = { navItems: {}, footerCopy: '', campaign: 'Comic Relief', - overrideWhiteList: false, + overrideallowList: false, additionalLegalLine: '' }; diff --git a/src/components/Organisms/Footer/Footer.md b/src/components/Organisms/Footer/Footer.md index 0bcc49974..33e3c0602 100644 --- a/src/components/Organisms/Footer/Footer.md +++ b/src/components/Organisms/Footer/Footer.md @@ -8,12 +8,12 @@ import footerCopy from './data/footerCopy';
Standard footer
-Overrides whitelist functionality for external usage
+Overrides allowList functionality for external usage
Adding a additionalLegalLine to the top of the footer
diff --git a/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap b/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap index 0cbe6ba3f..927ad2c01 100644 --- a/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +++ b/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap @@ -1206,7 +1206,7 @@ exports[`renders correctly 1`] = ` color="white" size="s" > - Test whitelisted external link + Test allowListed external link @@ -1226,7 +1226,7 @@ exports[`renders correctly 1`] = ` color="white" size="s" > - Test non-whitelisted external link + Test non-allowListed external link { /* Determine which field represents our url path */ let thisUrl = NavHelper(thisFirstChild); - const relNoopener = !whiteListed(thisUrl) && 'noopener'; + const relNoopener = !allowListed(thisUrl) && 'noopener'; const hasSubMenu = group.links && group.links.length > 1; const hasPopUp = hasSubMenu ? 'true' : null; thisUrl = InternalLinkHelper(thisUrl); diff --git a/src/components/Organisms/Header/data/data.js b/src/components/Organisms/Header/data/data.js index afe3d7fdd..98d161a1d 100644 --- a/src/components/Organisms/Header/data/data.js +++ b/src/components/Organisms/Header/data/data.js @@ -151,14 +151,14 @@ export default { id: 'eaec5191-bbb3-5e8d-b966-c53fff34998a', links: [ { - title: 'Test whitelisted external link', + title: 'Test allowListed external link', url: 'https://www.sportrelief.com', internal: { type: 'ContentfulComponentLink' } }, { - title: 'Test non-whitelisted external link', + title: 'Test non-allowListed external link', url: 'https://bing.com', internal: { type: 'ContentfulComponentLink' diff --git a/src/index.js b/src/index.js index c910383a3..dd721993c 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ export { default as ThemeProvider } from './theme/ThemeProvider'; /* Utils */ export { default as hideVisually } from './theme/shared/hideVisually'; export { default as zIndex } from './theme/shared/zIndex'; -export { default as whiteListed } from './utils/whiteListed'; +export { default as allowListed } from './utils/allowListed'; export { default as spacing } from './theme/shared/spacing'; export { default as breakpoint } from './theme/shared/breakpoint'; export { media, screen, container } from './theme/shared/size'; diff --git a/src/utils/whiteListed.js b/src/utils/whiteListed.js index da7726772..918407544 100644 --- a/src/utils/whiteListed.js +++ b/src/utils/whiteListed.js @@ -1,4 +1,4 @@ -const whiteList = [ +const allowList = [ 'https://giftaid.comicrelief.com', 'https://donation.comicrelief.com', 'https://www.comicrelief.com', @@ -8,15 +8,15 @@ const whiteList = [ 'https://form.typeform.com' ]; -const whiteListed = url => { +const allowListed = url => { if ( url !== undefined && url !== null - && whiteList.some(v => url.indexOf(v) >= 0) + && allowList.some(v => url.indexOf(v) >= 0) ) { return true; } return false; }; -export default whiteListed; +export default allowListed; diff --git a/src/utils/whiteListed.test.js b/src/utils/whiteListed.test.js index 21e7dac4d..fb9908559 100644 --- a/src/utils/whiteListed.test.js +++ b/src/utils/whiteListed.test.js @@ -1,9 +1,9 @@ -import whiteListed from './whiteListed'; +import allowListed from './allowListed'; -it('link is whitelisted', () => { - expect(whiteListed('https://www.comicrelief.com/home')).toBe(true); +it('link is allowListed', () => { + expect(allowListed('https://www.comicrelief.com/home')).toBe(true); }); -it('link is not whitelisted', () => { - expect(whiteListed('https://www.google.co.uk/')).toBe(false); +it('link is not allowListed', () => { + expect(allowListed('https://www.google.co.uk/')).toBe(false); });