@@ -45,12 +45,11 @@ pub fn detect_image_reference(text: &str) -> Option<ImageReference> {
4545 let trimmed = text. trim ( ) ;
4646
4747 // Strip common trailing punctuation that might be attached to paths in sentences
48- let cleaned = trimmed. trim_end_matches ( |c| matches ! ( c , '.' | ',' | ';' | ':' | '!' | '?' ) ) ;
48+ let cleaned = trimmed. trim_end_matches ( [ '.' , ',' , ';' , ':' , '!' , '?' ] ) ;
4949
50- if cleaned. starts_with ( "http://" ) || cleaned. starts_with ( "https://" ) {
51- if is_image_url ( cleaned) {
52- return Some ( ImageReference :: WebUrl ( cleaned. to_string ( ) ) ) ;
53- }
50+ if ( cleaned. starts_with ( "http://" ) || cleaned. starts_with ( "https://" ) ) && is_image_url ( cleaned)
51+ {
52+ return Some ( ImageReference :: WebUrl ( cleaned. to_string ( ) ) ) ;
5453 }
5554
5655 if has_image_extension ( cleaned) {
@@ -239,12 +238,12 @@ impl ImageLoader {
239238pub fn extract_image_references ( input : & str ) -> ( String , Vec < ImageReference > ) {
240239 let mut remaining_text = String :: new ( ) ;
241240 let mut references = Vec :: new ( ) ;
242- let mut chars = input. chars ( ) . peekable ( ) ;
241+ let chars = input. chars ( ) ;
243242 let mut current_word = String :: new ( ) ;
244243 let mut in_quotes = false ;
245244 let mut quote_char = ' ' ;
246245
247- while let Some ( ch ) = chars. next ( ) {
246+ for ch in chars {
248247 match ch {
249248 // Only treat quotes as delimiters if we're at a word boundary (current_word is empty)
250249 // This prevents apostrophes in contractions like "don't" from being treated as quotes
0 commit comments