isPathWithinRoots method

bool isPathWithinRoots(
  1. String sessionId,
  2. String path
)

Check if a path is within client roots

Implementation

bool isPathWithinRoots(String sessionId, String path) {
  final session = _sessions[sessionId];
  if (session == null) return false;

  if (session.roots.isEmpty) return true; // No roots defined means all paths allowed

  for (final root in session.roots) {
    final rootUri = root['uri'] as String?;
    if (rootUri != null && path.startsWith(rootUri)) {
      return true;
    }
  }

  return false;
}