appendWsUrls function
Converts an array of chronik http/https urls into websocket equivalents and combines them into an object array
Implementation
List<Endpoint> appendWsUrls(List<String> urls) {
final combinedUrls = <Endpoint>[];
for (final thisUrl in urls) {
if (thisUrl.startsWith('https://')) {
combinedUrls.add(
Endpoint(
url: thisUrl,
wsUrl: 'wss://${thisUrl.substring('https://'.length)}/ws',
),
);
} else if (thisUrl.startsWith('http://')) {
combinedUrls.add(
Endpoint(
url: thisUrl,
wsUrl: 'ws://${thisUrl.substring('http://'.length)}/ws',
),
);
} else {
throw ValidationException('Invalid url found in array: $thisUrl');
}
}
return combinedUrls;
}