isFetchAllowed function

bool isFetchAllowed(
  1. Uri uri
)

Whether uri may be fetched: https:, or plain http: to this machine only.

Implementation

bool isFetchAllowed(Uri uri) {
  if (uri.scheme == 'https') return true;
  if (uri.scheme != 'http') return false;
  return uri.host == 'localhost' ||
      uri.host == '127.0.0.1' ||
      uri.host == '::1';
}