servingAddress function

String? servingAddress(
  1. String line
)

The address a service announced it is listening on, read off its own Serving at … line, or null if line is not one.

Read from the child's output rather than reassembled from the plan's port because the line carries the app prefix too — revali up assigns the port but has no idea the app mounts itself under /api, and a base without the prefix sends every route click to a 404.

Returned as written, wildcard host and all. Rewriting happens where a URL is launched (launchableUrl), so there is one place that decides it.

Implementation

String? servingAddress(String line) {
  final plain = stripAnsi(line);
  final index = plain.indexOf(_servingMarker);
  if (index == -1) return null;

  final rest = plain.substring(index + _servingMarker.length).trim();
  if (rest.isEmpty) return null;

  // Whitespace-delimited: `mason_logger` may have appended nothing, but a
  // future suffix must not become part of the address.
  final address = rest.split(RegExp(r'\s')).first;

  return launchableUrl(address) == null ? null : address;
}