dvHostedLocation function
The Dartvel path a host location names under at, or null when it is
not one of routes: the host's own route, which the host handles.
Implementation
String? dvHostedLocation(
String location,
List<RouteBase> routes, {
String at = '/',
}) {
final Uri uri = Uri.parse(location);
String path = uri.path.isEmpty ? '/' : uri.path;
if (at != '/') {
if (path == at) {
path = '/';
} else if (path.startsWith('$at/')) {
path = path.substring(at.length);
} else {
return null;
}
}
final bool ours = dvRoutePaths(routes)
.any((String pattern) => dvRoutesOverlap(path, pattern));
if (!ours) return null;
return uri.replace(path: path).toString();
}