isInSandbox method

bool isInSandbox(
  1. String path
)

Whether the given path falls inside any allowed sandbox path.

Implementation

bool isInSandbox(String path) {
  final normalized = _normalizePath(path);
  for (final allowed in _allowedPaths) {
    final normalizedAllowed = _normalizePath(allowed);
    if (normalized == normalizedAllowed ||
        normalized.startsWith('$normalizedAllowed/')) {
      return true;
    }
  }
  return false;
}