linkIsInternal: add test to ensure we don't regress on cases of SLDs

This commit is contained in:
Ronan Jouchet 2021-04-30 07:52:58 -04:00
parent c4356e48f1
commit 1ad1844619
1 changed files with 7 additions and 0 deletions

View File

@ -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',