issuerKey function

String issuerKey(
  1. String issuer
)

Normalize an issuer URL to a consistent keychain key. Strips trailing slashes and lowercases the host portion.

Implementation

String issuerKey(String issuer) {
  try {
    final uri = Uri.parse(issuer);
    final normalized = uri.replace(
      host: uri.host.toLowerCase(),
      path: uri.path.endsWith('/')
          ? uri.path.substring(0, uri.path.length - 1)
          : uri.path,
    );
    return normalized.toString();
  } catch (_) {
    return issuer;
  }
}