Skip to content

Commit

Permalink
Fixing the "try the v5 site" link in the docs site (keystonejs#6411)
Browse files Browse the repository at this point in the history
* Fixing the "try the v5 site" link in the docs site

* Adding a note on security and a (redundant) check for a leading slash in the path
  • Loading branch information
molomby authored and Nikitoring committed Sep 14, 2021
1 parent 262a7ec commit 1cf4ae6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ function ConstructionIllustration() {
);
}

// Modifying this code may have security implications
// See.. https://github.com/keystonejs/keystone/pull/6411#issuecomment-906085389
const v5PathList = ['/tutorials', '/guides', '/keystonejs', '/api', '/discussions'];

export default function NotFoundPage() {
const { asPath } = useRouter();
const tryV5Link = v5PathList.some(i => asPath.startsWith(i));
const tryV5Link = asPath.startsWith('/') && v5PathList.some(i => asPath.startsWith(i));
return (
<Page title={'Page Not Found (404)'} description={'Page Not Found (404)'}>
<div
Expand All @@ -53,7 +55,7 @@ export default function NotFoundPage() {
{tryV5Link ? (
<Type as="p" look="body18bold" margin="2rem 0 0">
If you were looking for a page in the Keystone 5 docs, try{' '}
<a href="https://v5.keystonejs.com">v5.keystonejs.com{asPath}</a>.
<a href={'https://v5.keystonejs.com' + asPath}>https://v5.keystonejs.com{asPath}</a>.
</Type>
) : null}
<ConstructionIllustration />
Expand Down

0 comments on commit 1cf4ae6

Please sign in to comment.