File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,10 @@ class MiabClient {
290290 filterEmails ( emails , options = { } ) {
291291 let { regex = [ ] , from = '' , subject = '' } = options ;
292292
293+ if ( regex . length === 0 && from === '' && subject === '' ) {
294+ throw new Error ( 'At least one option must be specified. All options cannot be default values.' ) ;
295+ }
296+
293297 if ( ! Array . isArray ( regex ) ) {
294298 console . error ( 'The regex option must be an array. Trying to experimentally convert it to an array.' ) ;
295299
@@ -302,14 +306,14 @@ class MiabClient {
302306
303307 return emails . filter ( email => {
304308 // Check if the email matches the regex patterns.
305- const regexMatch = regex . some ( r => {
309+ const regexMatch = Array . isArray ( regex ) ? regex . some ( r => {
306310 if ( this . #isRegex( r ) ) {
307311 const regex = new RegExp ( r ) ;
308312 return regex . test ( email . textAsHtml ) || regex . test ( email . text ) ;
309313 } else {
310314 return email . textAsHtml . includes ( r ) || email . text . includes ( r ) ;
311315 }
312- } ) ;
316+ } ) : true ;
313317
314318 // Check if the email is from the specified sender.
315319 const fromMatch = from ? email . from . text . includes ( from ) : true ;
You can’t perform that action at this time.
0 commit comments