launchableUrl function

String? launchableUrl(
  1. String raw
)

raw as something a browser can be pointed at, or null if it is not a URL.

A wildcard bind address is rewritten. 0.0.0.0 and :: mean "every interface" to a listening socket and mean nothing at all to a client — a browser given http://0.0.0.0:8080 either fails outright or is quietly rescued by the OS, and neither is something to rely on. The displayed text is left exactly as the child wrote it: it is the truth about what the service bound, and rewriting it on screen would be this side lying about the other side's output.

Implementation

String? launchableUrl(String raw) {
  final uri = Uri.tryParse(raw);
  if (uri == null) return null;
  if (!uri.hasScheme || !_launchableSchemes.contains(uri.scheme)) return null;
  if (uri.host.isEmpty) return null;

  if (_wildcardHosts.contains(uri.host)) {
    return uri.replace(host: 'localhost').toString();
  }

  return uri.toString();
}