Files
pipelines/app/lib/features/settings/default_endpoint.dart
T
alan abd696b0d9 feat(app): add native Settings connection and workspace screen
Add the Settings destination under lib/features/settings with an editable
websocket endpoint, truthful connection states, one ping per connect/mount,
workspace validation and persistence under new feature-owned keys. Material
and Cupertino controls, wrapping copy at large text, pending ping state, and
isolated probe tools plus widget/unit coverage.
2026-10-21 17:39:18 +01:00

25 lines
1002 B
Dart

import 'package:flutter/foundation.dart';
/// The websocket endpoint the web build offers by default: the page's own
/// origin, upgraded to ws/wss, at the server's `/connect` path.
///
/// The web client is served by a same-origin proxy, so this is a configurable
/// starting value, not a baked host: it is derived from the page the operator
/// actually loaded. Native builds have no such origin and start blank, so no
/// server host or production endpoint is compiled into the app.
///
/// `web` and `base` are injectable only so the rule can be tested without a
/// browser; production callers use the platform defaults.
String defaultServerUrl({bool? web, Uri? base}) {
if (!(web ?? kIsWeb)) return '';
final origin = base ?? Uri.base;
if (origin.host.isEmpty) return '';
final secure = origin.scheme.toLowerCase() == 'https';
return Uri(
scheme: secure ? 'wss' : 'ws',
host: origin.host,
port: origin.hasPort ? origin.port : null,
path: '/connect',
).toString();
}