Repository: manusa/electronim (js)

Issue:
Tweetdeck opens the web page on pressing Login button
When trying to add the Tweetdeck, the multi-account Twitter client service[1], when you press the "Login" button, the web page opens in a new tab in your default browser and the tab in Electronim stays in the same page.

Tested both with Sandbox and without.

[1] https://tweetdeck.twitter.com/

Pull request description:
🐞: Fix login to Tweet Deck is now possible
Fixes #49 

Patch:
diff --git a/src/tab-manager/redirect.js b/src/tab-manager/redirect.js
index 46e045c..0ae5a0e 100644
--- a/src/tab-manager/redirect.js
+++ b/src/tab-manager/redirect.js
@@ -30,7 +30,8 @@ const isOAuth = matchUrls([
   /^https:\/\/login\.microsoftonline\.com\/.*/, // NOSONAR
   /^https:\/\/.+\.skype\.com\/login\/.*/, // NOSONAR
   /^https:\/\/.+\.skype\.com\/Auth\/.*/, // NOSONAR
-  /^https:\/\/idbroker\.webex\.com\/idb\/oauth2\/.*/ // NOSONAR
+  /^https:\/\/idbroker\.webex\.com\/idb\/oauth2\/.*/, // NOSONAR
+  /^https:\/\/.+\.twitter\.com\/login.*/ // NOSONAR
 ]);
 
 const isSameOrigin = (browserViewUrl, url) => url.origin === browserViewUrl.origin;


Test patch:
diff --git a/src/tab-manager/__tests__/redirect.test.js b/src/tab-manager/__tests__/redirect.test.js
index d5d7de5..983a264 100644
--- a/src/tab-manager/__tests__/redirect.test.js
+++ b/src/tab-manager/__tests__/redirect.test.js
@@ -122,5 +122,23 @@ describe('Tab Manager Redirect module test suite', () => {
         expect(result).toBe(false);
       });
     });
+    describe('Twitter login', () => {
+      test('From Tweet Deck to Twitter, should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://tweetdeck.twitter.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView, new URL('https://mobile.twitter.com/login?hide_message=true&redirect_after_login=https%3A%2F%2Ftweetdeck.twitter.com%2F%3Fvia_twitter_login%3Dtrue'));
+        // Then
+        expect(result).toBe(false);
+      });
+      test('From Twitter to Tweet Deck , should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://mobile.twitter.com/login';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView, new URL('https://tweetdeck.twitter.com?via_twitter_login=true'));
+        // Then
+        expect(result).toBe(false);
+      });
+    });
   });
 });