normalizeAttachDebugUrl function

String normalizeAttachDebugUrl(
  1. String debugUrl
)

Implementation

String normalizeAttachDebugUrl(String debugUrl) {
  var normalized = debugUrl.trim();
  if (normalized.startsWith('ws://')) {
    normalized = 'http://${normalized.substring(5)}';
  } else if (normalized.startsWith('wss://')) {
    normalized = 'https://${normalized.substring(6)}';
  }

  if (normalized.endsWith('/ws/')) {
    return normalized.substring(0, normalized.length - 3);
  }
  if (normalized.endsWith('/ws')) {
    return normalized.substring(0, normalized.length - 2);
  }
  return normalized;
}