Skip to content

Commit 2fe1902

Browse files
anvansterclaude
andcommitted
refactor: trim both path separators at get_module_summary entry (#5)
prefix only feeds path_matches (which re-normalises internally), but the 'Normalise' comment promised more than trim_end_matches('/') delivered — a trap for future direct consumers of the prefix. Behaviour-identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8f61bb5 commit 2fe1902

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

crates/codegraph-server/src/domain/module_summary.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ pub(crate) fn get_module_summary(
6060
directory: &str,
6161
top_n: usize,
6262
) -> ModuleSummaryResult {
63-
// Normalise: strip trailing slash so prefix matching is consistent.
64-
let prefix = directory.trim_end_matches('/');
63+
// Normalise: strip trailing separators (either flavour — Windows callers
64+
// pass `\`) so prefix matching is consistent. path_matches() re-normalises
65+
// separators internally, but anything else that ever consumes `prefix`
66+
// directly should see a clean value too.
67+
let prefix = directory.trim_end_matches(['/', '\\']);
6568

6669
let mut files: usize = 0;
6770
let mut total_functions: usize = 0;

0 commit comments

Comments
 (0)