@@ -2,7 +2,7 @@ use serde::Serialize;
22
33use grapha_core:: graph:: { Graph , NodeRole } ;
44
5- use super :: { SymbolRef , file_matches_query_path } ;
5+ use super :: { SymbolRef , file_matches_path_or_suffix } ;
66
77#[ derive( Debug , Clone , Default ) ]
88pub struct EntriesQueryOptions {
@@ -39,13 +39,13 @@ pub fn query_entries_with_options(graph: &Graph, options: &EntriesQueryOptions)
3939 options
4040 . module
4141 . as_deref ( )
42- . map_or ( true , |module| node. module . as_deref ( ) == Some ( module) )
42+ . is_none_or ( |module| node. module . as_deref ( ) == Some ( module) )
4343 } )
4444 . filter ( |node| {
4545 options
4646 . file
4747 . as_deref ( )
48- . map_or ( true , |file_query| file_matches_query_path ( & node. file , file_query) )
48+ . is_none_or ( |file_query| file_matches_path_or_suffix ( & node. file , file_query) )
4949 } )
5050 . map ( SymbolRef :: from_node)
5151 . collect ( ) ;
@@ -192,11 +192,7 @@ mod tests {
192192 (
193193 entry. id . as_str ( ) ,
194194 entry. name . as_str ( ) ,
195- entry
196- . file
197- . rsplit ( '/' )
198- . next ( )
199- . unwrap_or ( entry. file . as_str ( ) ) ,
195+ entry. file . rsplit ( '/' ) . next ( ) . unwrap_or ( entry. file . as_str ( ) ) ,
200196 entry. module . as_deref ( ) ,
201197 )
202198 } )
@@ -207,4 +203,30 @@ mod tests {
207203 assert_eq ! ( result. total, 2 ) ;
208204 assert_eq ! ( result. shown, 1 ) ;
209205 }
206+
207+ #[ test]
208+ fn file_filter_does_not_match_partial_fragments ( ) {
209+ let graph = Graph {
210+ version : "0.1.0" . to_string ( ) ,
211+ nodes : vec ! [ entry_node(
212+ "room_body" ,
213+ "body" ,
214+ "Modules/Room/Sources/Room/View/RoomPage.swift" ,
215+ Some ( "Room" ) ,
216+ ) ] ,
217+ edges : vec ! [ ] ,
218+ } ;
219+
220+ let result = query_entries_with_options (
221+ & graph,
222+ & EntriesQueryOptions {
223+ file : Some ( "Page" . to_string ( ) ) ,
224+ ..EntriesQueryOptions :: default ( )
225+ } ,
226+ ) ;
227+
228+ assert_eq ! ( result. total, 0 ) ;
229+ assert_eq ! ( result. shown, 0 ) ;
230+ assert ! ( result. entries. is_empty( ) ) ;
231+ }
210232}
0 commit comments