toSearchableUrl method

String toSearchableUrl()

Implementation

String toSearchableUrl() {
  final hostParts = host.split('.').reversed.join(',');
  final schemeLC = scheme.toLowerCase();
  final emitScheme = hasScheme &&
      schemeLC.isNotEmpty &&
      schemeLC != 'http' &&
      schemeLC != 'https';
  return [
    if (emitScheme) '$schemeLC://',
    hostParts,
    if (hasPort) ':$port',
    if (hostParts.isNotEmpty) ')',
    path,
    if (hasQuery) '?$query',
  ].join('');
}