feat: Allow localhost connection strings#118
feat: Allow localhost connection strings#118elliott-with-the-longest-name-on-github merged 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: d932029 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| try { | ||
| // This seems silly, but we can use all of the hard work put into URL parsing | ||
| // if we just convert `postgresql://` to `https://` and then parse it as a URL. | ||
| const withHttpsProtocol = connectionString.startsWith('postgresql://') |
There was a problem hiding this comment.
I think this should work without replacing the protocol before parsing the URL:
> new URL("postgresql://localhost:5432")
URL {
href: 'postgresql://localhost:5432',
origin: 'null',
protocol: 'postgresql:',
username: '',
password: '',
host: 'localhost:5432',
hostname: 'localhost',
port: '5432',
pathname: '',
search: '',
searchParams: URLSearchParams {},
hash: ''
}
There was a problem hiding this comment.
It does not in some cases 😢 Try running the tests without it.
There was a problem hiding this comment.
TIL that most browsers don’t follow the WHATWG URL spec when it comes to parsing URLs with unknown protocols (example). Parsing postgresql: connection strings with Node.js should work, though (the tests are all passing). 🤔

If a connection string is on
localhost, don't check for whether it's pooled or non-pooled. Just allow it.