dvIsErrorPageRoute function
Whether path is one of the two error routes.
Reads the path as the request was written, because that is all a build
gets: the same page is asked about as /offline, as /offline/ by a
static host serving a directory index, and as
/offline?from=%2Farticles when the worker redirected a person to it.
Query and fragment are dropped first, and the route must be the whole
path.
A site served under a mount is asked about its routes with the mount
already stripped, the same as every other route, so a build mounts its
answer rather than guessing at one here — and a nested /blog/404 is
still a real page whose slug is 404, which this must not swallow.
Implementation
bool dvIsErrorPageRoute(String path) {
if (path.isEmpty) return false;
final Uri? uri = Uri.tryParse(path);
if (uri == null) return false;
if (uri.hasScheme || uri.hasAuthority) return false;
String route = uri.path;
while (route.endsWith('/')) {
route = route.substring(0, route.length - 1);
}
return route == dvNotFoundRoute || route == dvOfflineRoute;
}