dvStudioSignInTarget function

String dvStudioSignInTarget(
  1. String mount,
  2. String? from, {
  3. List<String> also = const <String>[],
})

Where, inside mount, a person signing in is sent afterwards.

Only a path inside the mount, or inside one of also -- the other mounts Studio's grant guards and sends here to sign in, such as a documentation site with access: studio -- and never the sign-in itself. Anything else -- another site, a protocol-relative //host, a page of the application -- is Studio's front page: a sign-in that could be pointed anywhere is a link somebody can send a person to.

Implementation

String dvStudioSignInTarget(String mount, String? from,
    {List<String> also = const <String>[]}) {
  final String home = '$mount/';
  final String value = from ?? '';
  if (value.contains('//') || value.contains('\\')) return home;
  bool under(String base) => value == base || value.startsWith('$base/');
  final bool inside = under(mount) || also.any(under);
  final bool login =
      value == '$mount/login' || value.startsWith('$mount/login?');
  return inside && !login ? value : home;
}