Support bracketed IPv6 hosts in connection strings - #1233
Open
Nitjsefnie wants to merge 1 commit into
Open
Nitjsefnie wants to merge 1 commit into
Nitjsefnie wants to merge 1 commit into
Conversation
Co-Authored-By: GPT-6 Sol <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Connection strings with a bracketed IPv6 host (
postgres://u:p@[::1]:5432/db) resolved to host[and could not connect; each host entry is now parsed with bracket awareness, and a bare IPv6hostoption orPGHOSTvalue is kept whole.Related Issues and Pull Requests
Fixes #1232
Relates to #663
Relates to #1127
Changes
src/index.js:parseOptionsmaps each comma-separated host entry through a smallparseHosthelper.[addr]/[addr]:portyieldsaddrand that port (or the default), an unbracketed value with more than one:(a bare IPv6 address such as::1) is taken whole, and everything else is split at:exactly as before, so hostname, IPv4,host:port, multi-host and socket-path behaviour is unchanged.tests/index.js: five cases next toMultiple hosts— bracketed IPv6 with and without a port, two bracketed hosts, a bare::1hostoption, and the existingh1:1,h2:2form.cjs/,deno/,cf/: the matchingnpm run buildoutput for those two files only.ERR_INVALID_URLfor a bare::1hostoption and has no tests; refactor: Use new URL for connection string parsing #1127 turns a multi-host entry[::1]:5432into host::1]:543.Testing
master('[["::1"],[5432]]' != '[["["],[5432]]') and pass with the change.node tests/index.jsandnode cjs/tests/index.jspassed against a local PostgreSQL with the second server on port 5433, as in CI. Two existing timing-sensitive tests (reserve connection,listen and notify with weird name) failed on earlier runs and passed on re-run; they do not touch host parsing.npm run lintpassed.::1.Footer
Generated by Claude Opus 5.5 (brief, review), GPT-6 Sol (implementation, review)