dvStudioStructureName function
The file name a route's captured structure is kept under, as the build's
semantics capture names it: / is index, /docs/cli is docs_cli.
Null for a route that could name a file outside the directory.
Implementation
String? dvStudioStructureName(String route) {
if (!route.startsWith('/') || route.contains('..') || route.contains(r'\')) {
return null;
}
final String name = route == '/'
? 'index'
: route.replaceAll(RegExp(r'^/|/$'), '').replaceAll('/', '_');
if (name.isEmpty || !RegExp(r'^[A-Za-z0-9_\-.:\[\]{}]+$').hasMatch(name)) {
return null;
}
return name;
}