in crates/core/src/models/rule.rs [275:301]
fn paths_match_directory_scope(file_path: &Path, scope_dir: &Path, recursive: bool) -> bool {
// Get parent directory of the file
let file_dir = match file_path.parent() {
Some(dir) => dir,
None => return false,
};
// Try to canonicalize both paths to handle symlinks, relative paths, etc.
let canonical_file_dir = file_dir
.canonicalize()
.unwrap_or_else(|_| file_dir.to_path_buf());
let canonical_scope_dir = scope_dir
.canonicalize()
.unwrap_or_else(|_| scope_dir.to_path_buf());
if recursive {
// DirectoryRecursive: file directory should be same as or under scope directory
// Use strip_prefix for proper path hierarchy checking instead of starts_with
canonical_file_dir == canonical_scope_dir
|| canonical_file_dir
.strip_prefix(&canonical_scope_dir)
.is_ok()
} else {
// Directory: file directory should be exactly the same as scope directory
canonical_file_dir == canonical_scope_dir
}
}