(credentials: DatabaseCredentials)
| 19 | const simpleUnixPathPattern = /^\.{0,2}\// |
| 20 | |
| 21 | export function getSocketFromDatabaseCredentials(credentials: DatabaseCredentials): string | null { |
| 22 | if (['postgres', 'postgresql', 'cockroachdb'].includes(credentials.type)) { |
| 23 | const host = credentials.host |
| 24 | |
| 25 | if (typeof host === 'string' && simpleUnixPathPattern.test(host)) { |
| 26 | return host |
| 27 | } |
| 28 | |
| 29 | return null |
| 30 | } |
| 31 | |
| 32 | return credentials.socket ?? null |
| 33 | } |
no test coverage detected