@@ -133,18 +133,31 @@ async function filterMailsRegex(searchOptions, tabId = null) {
133133 const group = searchOptions . group ; // 0 for full match
134134 const searchSelected = searchOptions . searchSelected ;
135135 const searchCriteria = searchOptions . searchCriteria ; // if fields is null, do not change this!
136- let pattern = searchOptions . pattern ; // allow overwriting in debugger for test!
137- const isEmpty = ( ! pattern ) ; // non empty search string, reset!
136+ let searchValue = searchOptions . pattern , // allow overwriting in debugger for test!
137+ searchFlags = "" ;
138138 const behavior = searchOptions . behavior || DEFAULT_BEHAVIOR ;
139139
140+ if ( searchValue . charAt ( 0 ) == "/" ) {
141+ let endIdx = searchValue . lastIndexOf ( "/" ) ;
142+ if ( endIdx ) { // must be>0! otherwise 2nd slash is missing!!
143+ searchValue = searchOptions . pattern . substring ( 1 , endIdx ) ;
144+ searchFlags = searchOptions . pattern . substring ( endIdx + 1 ) ;
145+ } else {
146+ const isDebug = await messenger . LegacyPrefs . getPref ( legacyPrefPath ( "debug" ) ) ;
147+ if ( isDebug ) {
148+ console . log ( `Invalid search string in find Related - missing 2nd '/' : ${ searchFlags } ` ) ;
149+ }
150+ searchFlags = searchOptions . pattern . substring ( 1 ) ; // removing beginning '/'
151+ }
152+ }
153+
154+ if ( ! searchFlags ) {
155+ searchFlags = "gm" ;
156+ }
140157
141- const regex = new RegExp ( pattern , "gm" ) ;
158+ const regex = new RegExp ( searchValue , searchFlags ) ;
142159 let results , searchVal = "" ;
143160
144- if ( isEmpty ) {
145- // reset search!
146- }
147-
148161 // context.extension.tabManager.getWrapper(tabInfo).id
149162 if ( ! tabId ) {
150163 const currentTab = await messenger . tabs . getCurrent ( ) ;
0 commit comments