Repository: manusa/electronim
Pull request #416 (2024-05-30 02:08:34)

✨ support for X (Tweeter) OAuth URLs

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=manusa_electronim&pullRequest=416) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=416&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=416&resolutions=WONTFIX)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=manusa_electronim&pullRequest=416&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=416&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=manusa_electronim&pullRequest=416)



Patch:
diff --git a/src/tab-manager/redirect.js b/src/tab-manager/redirect.js
index 1e96927..3d8c7fb 100644
--- a/src/tab-manager/redirect.js
+++ b/src/tab-manager/redirect.js
@@ -36,6 +36,9 @@ const isOAuth = matchUrls([
   /^https:\/\/.+\.skype\.com\/Auth\/.*/, // NOSONAR
   /^https:\/\/.+\.twitter\.com\/login.*/, // NOSONAR
   /^https:\/\/.+\.twitter\.com\/logout.*/, // NOSONAR
+  /^https:\/\/twitter\.com\/x.*/, // NOSONAR
+  /^https:\/\/x\.com\/login.*/, // NOSONAR
+  /^https:\/\/x\.com\/logout.*/, // NOSONAR
   /^https:\/\/idbroker\.webex\.com\/idb\/oauth2\/.*/, // NOSONAR
   /^https:\/\/accounts\.zoho\.(eu|com)\/signin.*/, // NOSONAR
   /^https:\/\/.+\.zoom\.us\/profile.*/, // NOSONAR


Test patch:
diff --git a/src/tab-manager/__tests__/redirect.test.js b/src/tab-manager/__tests__/redirect.test.js
index f33ab31..016154d 100644
--- a/src/tab-manager/__tests__/redirect.test.js
+++ b/src/tab-manager/__tests__/redirect.test.js
@@ -206,6 +206,32 @@ describe('Tab Manager Redirect module test suite', () => {
         expect(result).toBe(false);
       });
     });
+    describe('X login', () => {
+      test('From Twitter to X, should return false', () => {
+        // Given
+        mockViewUrl = 'https://twitter.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockView, new URL('https://x.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 X to Tweeter , should return false', () => {
+        // Given
+        mockViewUrl = 'https://x.com/login';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockView, new URL('https://twitter.com?via_twitter_login=true'));
+        // Then
+        expect(result).toBe(false);
+      });
+      test('From Tweeter to logout, should return false', () => {
+        // Given
+        mockViewUrl = 'https://twitter.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockView, new URL('https://x.com/logout'));
+        // Then
+        expect(result).toBe(false);
+      });
+    });
     describe('Zoho login', () => {
       test('From Zoho mail to login, should return false', () => {
         // Given