@@ -289,6 +289,37 @@ export class ModuleRaid {
289289 this . entrypoint = windowObjects [ 0 ]
290290 }
291291
292+ /**
293+ * Recursive object-search function for modules
294+ *
295+ * @param object the object to search through
296+ * @param query the query the object keys/values are searched for
297+ * @returns boolean state of `object` containing `query` somewhere in it
298+ * @internal
299+ */
300+ private searchObject ( object : any , query : string ) : boolean {
301+ for ( const key in object ) {
302+ const value = object [ key ]
303+ const lowerCaseQuery = query . toLowerCase ( )
304+
305+ if ( typeof value != 'object' ) {
306+ const lowerCaseKey = key . toString ( ) . toLowerCase ( )
307+
308+ if ( lowerCaseKey . includes ( lowerCaseQuery ) ) return true
309+
310+ if ( typeof value != 'object' ) {
311+ const lowerCaseValue = value . toString ( ) . toLowerCase ( )
312+
313+ if ( lowerCaseValue . includes ( lowerCaseQuery ) ) return true
314+ } else {
315+ if ( this . searchObject ( value , query ) ) return true
316+ }
317+ }
318+ }
319+
320+ return false
321+ }
322+
292323 /**
293324 * Method to search through the module object, searching for the fitting content
294325 * if a string is supplied
@@ -337,15 +368,7 @@ export class ModuleRaid {
337368 if ( ( module as AnyFunction ) . toString ( ) . toLowerCase ( ) . includes ( query ) ) results . push ( module )
338369 break
339370 case 'object' :
340- if ( typeof module . default === 'object' ) {
341- for ( key in module . default ) {
342- if ( key . toLowerCase ( ) === query ) results . push ( module )
343- }
344- }
345-
346- for ( key in module ) {
347- if ( key . toLowerCase ( ) === query ) results . push ( module )
348- }
371+ if ( this . searchObject ( module , query ) ) results . push ( module )
349372 break
350373 }
351374 } else if ( typeof query === 'function' ) {
0 commit comments