File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -287,8 +287,18 @@ class MiabClient {
287287 * @param {String } options.subject - The email subject.
288288 * @returns {ParsedMail[] }
289289 */
290- filterEmails ( emails , options ) {
291- const { regex, from, subject } = options ;
290+ filterEmails ( emails , options = { } ) {
291+ let { regex = [ ] , from = '' , subject = '' } = options ;
292+
293+ if ( ! Array . isArray ( regex ) ) {
294+ console . error ( 'The regex option must be an array. Trying to experimentally convert it to an array.' ) ;
295+
296+ if ( this . #isRegex( regex ) || typeof regex === 'string' ) {
297+ regex = [ regex ] ;
298+ } else {
299+ throw new Error ( 'The regex option must be an array and either a valid string or regex. Failed to experimentally convert it to an array.' ) ;
300+ }
301+ }
292302
293303 return emails . filter ( email => {
294304 // Check if the email matches the regex patterns.
You can’t perform that action at this time.
0 commit comments