unixSocketPath property

String? get unixSocketPath

The socket file when host is a path (/cloudsql/project:region:db), as libpq and Laravel read it: a directory gets .s.PGSQL.<port> appended. null for TCP hosts.

Implementation

String? get unixSocketPath {
  if (!host.startsWith('/')) {
    return null;
  }
  final file = '.s.PGSQL.$port';
  if (host.endsWith('/$file')) {
    return host;
  }
  return host.endsWith('/') ? '$host$file' : '$host/$file';
}