dvStudioSourcePath function

String? dvStudioSourcePath(
  1. String route
)

The file, relative to the project, that the document at route is kept in; null for a route that would name a file outside dvStudioSourceDirectory.

Implementation

String? dvStudioSourcePath(String route) {
  if (!route.startsWith('/') ||
      route.split('/').any((String part) => part == '..' || part == '.')) {
    return null;
  }
  if (route == _shortcutsRoute) return '$dvStudioSourceDirectory/shortcuts.json';
  if (route.startsWith(dvStudioComponentsPrefix)) {
    final String name = route.substring(dvStudioComponentsPrefix.length);
    if (name.isEmpty || name.contains('/')) return null;
    return '$dvStudioSourceDirectory/components/$name.json';
  }
  if (route.startsWith('/_dartvel/')) return null;
  final String path = route == '/' ? 'index' : route.substring(1);
  if (path.isEmpty || path.endsWith('/')) return null;
  return '$dvStudioSourceDirectory/pages/$path.json';
}