Improve the parsing of HostPorts received from MongoDB to work properly with with IPv6 addresses #21
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.
Improve the parsing of HostPorts received from MongoDB to work properly with with IPv6 addresses.
MongoDB's syntax is ambiguous and complex to deal with respect to IPv6 addresses, because the :
character is used to delimit both the parts of the IPv6 address, so the parser needs to be quite
complex.
This code will parse ambiguous examples like ::1:1234 as host ::1, port 1234, matching the approach
taken in MongoDB server codebase. If only one interpretation is possible, it will take that
interpretation. For example ::1:a is parsed as having no port specifier (since a is not a valid
decimal digit).
Also add a test program that tests the code with a number of cases.