codeMieApiBase function

String codeMieApiBase(
  1. String rawUrl
)

Normalizes an organization URL to the API base: https://hosthttps://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;
}