dvStudioSourceRoute function

String? dvStudioSourceRoute(
  1. String path
)

The route the file at path (relative to the project) is the document for, or null for a file that is not one of Studio's.

Implementation

String? dvStudioSourceRoute(String path) {
  final String p = path.replaceAll(r'\', '/');
  if (!p.endsWith('.json')) return null;
  if (p == '$dvStudioSourceDirectory/shortcuts.json') return _shortcutsRoute;
  const String components = '$dvStudioSourceDirectory/components/';
  if (p.startsWith(components)) {
    final String name = p.substring(components.length, p.length - 5);
    return name.contains('/') ? null : '$dvStudioComponentsPrefix$name';
  }
  const String pages = '$dvStudioSourceDirectory/pages/';
  if (!p.startsWith(pages)) return null;
  final String rest = p.substring(pages.length, p.length - 5);
  return rest == 'index' ? '/' : '/$rest';
}