From b27aeb11cac19936b1faa380a832e3781e3a5d19 Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Thu, 23 Dec 2021 01:02:35 -0600 Subject: [PATCH] fix: footer showing up on new RWD challenges (#44562) --- client/src/utils/path-parsers.test.ts | 24 ++++++++++++++++++++++++ client/src/utils/path-parsers.ts | 10 ++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/client/src/utils/path-parsers.test.ts b/client/src/utils/path-parsers.test.ts index 5e313c38a5..ad5a002f60 100644 --- a/client/src/utils/path-parsers.test.ts +++ b/client/src/utils/path-parsers.test.ts @@ -7,11 +7,23 @@ const pathnames = { challenge: '/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' }, + englishWithYear: { + landing: '/', + superBlock: '/learn/2022/responsive-web-design', + challenge: + '/learn/2022/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' + }, espanol: { landing: '/espanol', superBlock: '/espanol/learn/responsive-web-design', challenge: '/espanol/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' + }, + espanolWithYear: { + landing: '/espanol', + superBlock: '/espanol/learn/2022/responsive-web-design', + challenge: + '/espanol/learn/2022/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' } }; @@ -37,6 +49,12 @@ describe('isLanding', () => { it('returns false for English challenge pathname', () => { expect(isLanding(pathnames.english.challenge)).toBe(false); }); + it('returns false for English with year challenge pathname', () => { + expect(isLanding(pathnames.englishWithYear.challenge)).toBe(false); + }); + it('returns false for Espanol with year challenge pathname', () => { + expect(isLanding(pathnames.espanolWithYear.challenge)).toBe(false); + }); }); describe('isChallenge', () => { @@ -61,4 +79,10 @@ describe('isChallenge', () => { it('returns true for English challenge pathname', () => { expect(isChallenge(pathnames.english.challenge)).toBe(true); }); + it('returns true for English with year challenge pathname', () => { + expect(isChallenge(pathnames.englishWithYear.challenge)).toBe(true); + }); + it('returns true for Espanol with year challenge pathname', () => { + expect(isChallenge(pathnames.espanolWithYear.challenge)).toBe(true); + }); }); diff --git a/client/src/utils/path-parsers.ts b/client/src/utils/path-parsers.ts index bf15184d69..587606f409 100644 --- a/client/src/utils/path-parsers.ts +++ b/client/src/utils/path-parsers.ts @@ -7,8 +7,14 @@ const splitPath = (pathname: string): string[] => export const isChallenge = (pathname: string): boolean => { const pathArray = splitPath(pathname); return ( - (pathArray.length === 4 && pathArray[0]) === 'learn' || - (pathArray.length === 5 && pathArray[1]) === 'learn' + // learn/// + (pathArray.length === 4 && pathArray[0] === 'learn') || + // learn//// + (pathArray.length === 5 && pathArray[0] === 'learn') || + // /learn/// + (pathArray.length === 5 && pathArray[1] === 'learn') || + // /learn//// + (pathArray.length === 6 && pathArray[1] === 'learn') ); };