codeMieApiBase function
Normalizes an organization URL to the API base:
https://host → https://host/code-assistant-api (idempotent).
Implementation
String codeMieApiBase(String rawUrl) {
var base = rawUrl.trim().replaceAll(RegExp(r'/+$'), '');
if (!RegExp(
r'/code-assistant-api(/|$)',
caseSensitive: false,
).hasMatch(base)) {
base = '$base/code-assistant-api';
}
return base;
}