File tree Expand file tree Collapse file tree
extension/js/common/platform
test/source/tests/browser-unit-tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ export class Catch {
174174
175175 public static environment ( url = location . href ) : string {
176176 const browserName = Catch . browser ( ) . name ;
177- const origin = new URL ( location . href ) . origin ;
177+ const origin = new URL ( url ) . origin ;
178178 let env = 'unknown' ;
179179 if ( url . includes ( 'bnjglocicd' ) ) {
180180 env = 'ex:prod' ;
@@ -262,12 +262,14 @@ export class Catch {
262262 }
263263 }
264264 const exception = Catch . formExceptionFromThrown ( thrown ) ;
265+ const reportUrl = location . href . split ( '?' ) [ 0 ] ;
265266 return {
266267 name : exception . name . substring ( 0 , 50 ) ,
267268 message : Catch . groupSimilarReports ( exception . message . substring ( 0 , 200 ) ) ,
268- // Use https://mail.google.com/mail as URL for content script errors
269+ // Strip Gmail URLs to group similar errors from different threads/messages
269270 // https://github.com/FlowCrypt/flowcrypt-browser/issues/6031
270- url : Catch . RUNTIME_ENVIRONMENT === 'ex:s:gmail' ? 'https://mail.google.com/mail' : Catch . groupSimilarReports ( location . href . split ( '?' ) [ 0 ] ) ,
271+ // https://github.com/FlowCrypt/flowcrypt-browser/issues/6128
272+ url : Catch . RUNTIME_ENVIRONMENT . endsWith ( ':ex:s:gmail' ) ? 'https://mail.google.com/mail/' : Catch . groupSimilarReports ( reportUrl ) ,
271273 line : line || 1 ,
272274 col : col || 1 ,
273275 trace : Catch . groupSimilarReports ( exception . stack || '' ) ,
Original file line number Diff line number Diff line change @@ -70,3 +70,34 @@ BROWSER_UNIT_TEST_NAME(`Catcher does not include query string on report`);
7070 }
7171 return 'pass' ;
7272} ) ( ) ;
73+
74+ BROWSER_UNIT_TEST_NAME ( `Catcher reports correct URL for Gmail environment` ) ;
75+ ( async ( ) => {
76+ const originalEnv = Catch . RUNTIME_ENVIRONMENT ;
77+
78+ // https://github.com/FlowCrypt/flowcrypt-browser/issues/6128
79+ const sensitivePaths = [
80+ '/mail/u/0/#inbox/WhctKLbvMNLndrHSj' ,
81+ '/mail/u/0/#sent/KtbxLzFrMS' ,
82+ '/mail/u/1/#inbox/rtjXfHsNNgrJVZL' ,
83+ '/mail/u/1/#search/MSCGwzQrb' ,
84+ ] ;
85+
86+ try {
87+ for ( const path of sensitivePaths ) {
88+ const fullUrl = 'https://mail.google.com' + path ;
89+
90+ // Simulate environment detection based on the URL
91+ const env = Catch . environment ( fullUrl ) ;
92+ Catch . RUNTIME_ENVIRONMENT = env ;
93+
94+ const formatted = Catch . formatExceptionForReport ( { name : 'Error' } ) ;
95+ if ( formatted . url !== 'https://mail.google.com/mail/' ) {
96+ throw new Error ( `For path ${ path } , expected URL to be 'https://mail.google.com/mail/' but got '${ formatted . url } ' (env: ${ env } )` ) ;
97+ }
98+ }
99+ } finally {
100+ Catch . RUNTIME_ENVIRONMENT = originalEnv ;
101+ }
102+ return 'pass' ;
103+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments