From 5731a35d601a5cfbf744572bf811967972ce3453 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 22 Jun 2023 07:54:23 -0400 Subject: [PATCH] fix: regex lightning is surrounded by period --- .mocharc.json | 1 + src/common.ts | 2 +- test/common.test.ts | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.mocharc.json b/.mocharc.json index 19a5395c..e59ba8bf 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,6 +1,7 @@ { "require": "ts-node/register,source-map-support/register", "watch-extensions": "ts", + "watch-files": ["src", "test"], "recursive": true, "reporter": "spec", "timeout": 10000 diff --git a/src/common.ts b/src/common.ts index 596b1e52..b7ceaa65 100644 --- a/src/common.ts +++ b/src/common.ts @@ -35,7 +35,7 @@ export class Common { } const throwIfLightning = (urlString?: string): void => { - if (urlString?.match(/lightning\..*force\.com/)) { + if (urlString?.match(/\.lightning\..*force\.com/)) { throw new SfError(messages.getMessage('lightningInstanceUrl'), 'LightningDomain', [ messages.getMessage('flags.instance-url.description'), ]); diff --git a/test/common.test.ts b/test/common.test.ts index 9ae798c1..87199189 100644 --- a/test/common.test.ts +++ b/test/common.test.ts @@ -91,6 +91,12 @@ describe('common unit tests', () => { } }); + it('should allow a domain containing lightning in its login URL', async () => { + await projectSetup($$, true); + const loginUrl = await Common.resolveLoginUrl('https://mycompany-lightning.my.salesforce.com'); + expect(loginUrl).equals('https://mycompany-lightning.my.salesforce.com'); + }); + it('should throw on internal lightning login URL passed in to resolveLoginUrl()', async () => { await projectSetup($$, true); try {