@@ -318,7 +318,7 @@ impl Scanner {
318318 & mut self ,
319319 changed_content : ChangedContent ,
320320 ) -> Vec < ( String , usize ) > {
321- let content = read_changed_content ( changed_content) . unwrap_or_default ( ) ;
321+ let ( content, extension ) = read_changed_content ( changed_content) . unwrap_or_default ( ) ;
322322 let original_content = & content;
323323
324324 // Workaround for legacy upgrades:
@@ -328,7 +328,7 @@ impl Scanner {
328328 let content = content. replace ( "-[]" , "XYZ" ) ;
329329 let offset = content. as_ptr ( ) as usize ;
330330
331- let mut extractor = Extractor :: new ( & content[ ..] ) ;
331+ let mut extractor = Extractor :: new ( & content[ ..] , Some ( & extension ) ) ;
332332
333333 extractor
334334 . extract ( )
@@ -355,7 +355,7 @@ impl Scanner {
355355 }
356356}
357357
358- fn read_changed_content ( c : ChangedContent ) -> Option < Vec < u8 > > {
358+ fn read_changed_content ( c : ChangedContent ) -> Option < ( Vec < u8 > , String ) > {
359359 let ( content, extension) = match c {
360360 ChangedContent :: File ( file, extension) => match std:: fs:: read ( & file) {
361361 Ok ( content) => ( content, extension) ,
@@ -368,7 +368,7 @@ fn read_changed_content(c: ChangedContent) -> Option<Vec<u8>> {
368368 ChangedContent :: Content ( contents, extension) => ( contents. into_bytes ( ) , extension) ,
369369 } ;
370370
371- Some ( pre_process_input ( & content, & extension) )
371+ Some ( ( pre_process_input ( & content, & extension ) , extension) )
372372}
373373
374374pub fn pre_process_input ( content : & [ u8 ] , extension : & str ) -> Vec < u8 > {
@@ -389,7 +389,7 @@ pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
389389}
390390
391391#[ tracing:: instrument( skip_all) ]
392- fn read_all_files ( changed_content : Vec < ChangedContent > ) -> Vec < Vec < u8 > > {
392+ fn read_all_files ( changed_content : Vec < ChangedContent > ) -> Vec < ( Vec < u8 > , String ) > {
393393 event ! (
394394 tracing:: Level :: INFO ,
395395 "Reading {:?} file(s)" ,
@@ -403,16 +403,16 @@ fn read_all_files(changed_content: Vec<ChangedContent>) -> Vec<Vec<u8>> {
403403}
404404
405405#[ tracing:: instrument( skip_all) ]
406- fn parse_all_blobs ( blobs : Vec < Vec < u8 > > ) -> Vec < String > {
406+ fn parse_all_blobs ( blobs : Vec < ( Vec < u8 > , String ) > ) -> Vec < String > {
407407 let mut result: Vec < _ > = blobs
408408 . par_iter ( )
409- . flat_map ( |blob| blob. par_split ( |x| * x == b'\n' ) )
410- . filter_map ( |blob| {
409+ . flat_map ( |( blob, extension ) | blob. par_split ( |x| * x == b'\n' ) . map ( move |x| ( x , extension ) ) )
410+ . filter_map ( |( blob, extension ) | {
411411 if blob. is_empty ( ) {
412412 return None ;
413413 }
414414
415- let extracted = crate :: extractor:: Extractor :: new ( blob) . extract ( ) ;
415+ let extracted = crate :: extractor:: Extractor :: new ( blob, Some ( extension ) ) . extract ( ) ;
416416 if extracted. is_empty ( ) {
417417 return None ;
418418 }
0 commit comments