matchesNoProxyPattern function

bool matchesNoProxyPattern(
  1. String hostname,
  2. String pattern
)

Check if a hostname matches a NO_PROXY pattern.

Implementation

bool matchesNoProxyPattern(String hostname, String pattern) {
  final h = hostname.toLowerCase();
  final p = pattern.toLowerCase().trim();

  // Exact match
  if (h == p) return true;

  // Domain suffix with leading dot
  if (p.startsWith('.')) {
    return h == p.substring(1) || h.endsWith(p);
  }

  // Wildcard
  if (p == '*') return true;

  return false;
}