From 1ad1844619d561030ec1e9e13a5e6ce5eb15ceed Mon Sep 17 00:00:00 2001 From: Ronan Jouchet Date: Fri, 30 Apr 2021 07:52:58 -0400 Subject: [PATCH] linkIsInternal: add test to ensure we don't regress on cases of SLDs --- app/src/helpers/helpers.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/helpers/helpers.test.ts b/app/src/helpers/helpers.test.ts index 10db20d..16e775a 100644 --- a/app/src/helpers/helpers.test.ts +++ b/app/src/helpers/helpers.test.ts @@ -5,6 +5,7 @@ const internalUrlWww = 'https://www.medium.com/'; const sameBaseDomainUrl = 'https://app.medium.com/'; const internalUrlCoUk = 'https://medium.co.uk/'; const sameBaseDomainUrlCoUk = 'https://app.medium.co.uk/'; +const differentBaseDomainUrlCoUk = 'https://other.domain.co.uk/'; const internalUrlSubPath = 'topic/technology'; const externalUrl = 'https://www.wikipedia.org/wiki/Electron'; const wildcardRegex = /.*/; @@ -53,6 +54,12 @@ test('urls on the same "base domain" should be considered internal, long SLD', ( ).toEqual(true); }); +test('urls on the a different "base domain" are considered NOT internal, long SLD', () => { + expect( + linkIsInternal(internalUrlCoUk, differentBaseDomainUrlCoUk, undefined), + ).toEqual(false); +}); + const testLoginPages = [ 'https://amazon.co.uk/signin', 'https://amazon.com/signin',