@@ -442,19 +442,19 @@ mod tests {
442442 assert_eq ! ( text, "check out please" ) ;
443443
444444 // Test single-quoted path with spaces
445- let ( text, refs) = extract_image_references (
446- "view '/home/user/my photos/vacation.jpg' now" ,
445+ let ( text, refs) = extract_image_references ( "view '/home/user/my photos/vacation.jpg' now" ) ;
446+ assert_eq ! (
447+ refs. len( ) ,
448+ 1 ,
449+ "Should detect single-quoted path with spaces"
447450 ) ;
448- assert_eq ! ( refs. len( ) , 1 , "Should detect single-quoted path with spaces" ) ;
449451 assert ! (
450452 matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "/home/user/my photos/vacation.jpg" )
451453 ) ;
452454 assert_eq ! ( text, "view now" ) ;
453455
454456 // Test path with spaces at the end
455- let ( text, refs) = extract_image_references (
456- "\" /Users/alex/test/image file.png\" " ,
457- ) ;
457+ let ( text, refs) = extract_image_references ( "\" /Users/alex/test/image file.png\" " ) ;
458458 assert_eq ! ( refs. len( ) , 1 , "Should detect quoted path at end" ) ;
459459 assert ! (
460460 matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "/Users/alex/test/image file.png" )
@@ -465,10 +465,13 @@ mod tests {
465465 #[ test]
466466 fn test_extract_mixed_quoted_and_unquoted ( ) {
467467 // Mix of quoted path and unquoted path
468- let ( text, refs) = extract_image_references (
469- "compare \" file with space.png\" and simple.jpg" ,
468+ let ( text, refs) =
469+ extract_image_references ( "compare \" file with space.png\" and simple.jpg" ) ;
470+ assert_eq ! (
471+ refs. len( ) ,
472+ 2 ,
473+ "Should detect both quoted and unquoted paths"
470474 ) ;
471- assert_eq ! ( refs. len( ) , 2 , "Should detect both quoted and unquoted paths" ) ;
472475 assert ! ( matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "file with space.png" ) ) ;
473476 assert ! ( matches!( & refs[ 1 ] , ImageReference :: LocalPath ( p) if p == "simple.jpg" ) ) ;
474477 assert_eq ! ( text, "compare and" ) ;
@@ -477,9 +480,7 @@ mod tests {
477480 #[ test]
478481 fn test_extract_quoted_non_image ( ) {
479482 // Quoted text that's not an image should remain in text
480- let ( text, refs) = extract_image_references (
481- "the title is \" Hello World\" and image.png" ,
482- ) ;
483+ let ( text, refs) = extract_image_references ( "the title is \" Hello World\" and image.png" ) ;
483484 assert_eq ! ( refs. len( ) , 1 , "Should only detect the actual image" ) ;
484485 assert ! ( matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "image.png" ) ) ;
485486 assert_eq ! ( text, "the title is \" Hello World\" and" ) ;
@@ -488,20 +489,21 @@ mod tests {
488489 #[ test]
489490 fn test_extract_unclosed_quote ( ) {
490491 // Unclosed quote should be treated as regular text
491- let ( text, refs) = extract_image_references (
492- "this is \" unclosed quote and image.png" ,
493- ) ;
492+ let ( text, refs) = extract_image_references ( "this is \" unclosed quote and image.png" ) ;
494493 // The unclosed quote should make everything after it part of the text
495- assert_eq ! ( refs. len( ) , 0 , "Unclosed quote should prevent image detection" ) ;
494+ assert_eq ! (
495+ refs. len( ) ,
496+ 0 ,
497+ "Unclosed quote should prevent image detection"
498+ ) ;
496499 assert ! ( text. contains( "unclosed quote and image.png" ) ) ;
497500 }
498501
499502 #[ test]
500503 fn test_extract_web_url_with_spaces_quoted ( ) {
501504 // Web URLs with spaces (rare but possible)
502- let ( text, refs) = extract_image_references (
503- "see \" https://example.com/my image.png\" please" ,
504- ) ;
505+ let ( text, refs) =
506+ extract_image_references ( "see \" https://example.com/my image.png\" please" ) ;
505507 assert_eq ! ( refs. len( ) , 1 , "Should detect quoted URL with spaces" ) ;
506508 assert ! (
507509 matches!( & refs[ 0 ] , ImageReference :: WebUrl ( u) if u == "https://example.com/my image.png" )
@@ -513,19 +515,21 @@ mod tests {
513515 fn test_user_reported_case ( ) {
514516 // Exact case from user report: path with space but no quotes
515517 // This will NOT work without quotes - user needs to quote it
516- let ( _text, refs) = extract_image_references (
517- "/Users/alex/test/sofos_allowed/test_r copy.png" ,
518- ) ;
518+ let ( _text, refs) =
519+ extract_image_references ( "/Users/alex/test/sofos_allowed/test_r copy.png" ) ;
519520 // Without quotes, this gets split into two words
520521 // Only "copy.png" would be detected as an image
521522 assert_eq ! ( refs. len( ) , 1 , "Only the second part is detected as image" ) ;
522523 assert ! ( matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "copy.png" ) ) ;
523524
524525 // With quotes, it should work
525- let ( text, refs) = extract_image_references (
526- "\" /Users/alex/test/sofos_allowed/test_r copy.png\" " ,
526+ let ( text, refs) =
527+ extract_image_references ( "\" /Users/alex/test/sofos_allowed/test_r copy.png\" " ) ;
528+ assert_eq ! (
529+ refs. len( ) ,
530+ 1 ,
531+ "Quoted path should be detected as single image"
527532 ) ;
528- assert_eq ! ( refs. len( ) , 1 , "Quoted path should be detected as single image" ) ;
529533 assert ! (
530534 matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "/Users/alex/test/sofos_allowed/test_r copy.png" )
531535 ) ;
0 commit comments