fix: listening on IPv6 address not possible#5133
Merged
jsjoeio merged 1 commit intocoder:mainfrom Apr 26, 2022
Merged
Conversation
Wrap IPv6 addresses in square brackets when making URL in ensureAddress, fixing regression (coder#1582)
119e345 to
55bc52b
Compare
jsjoeio
reviewed
Apr 26, 2022
|
|
||
| if (typeof addr !== "string") { | ||
| return new URL(`${protocol}://${addr.address}:${addr.port}`) | ||
| const host = addr.family === "IPv6" ? `[${addr.address}]` : addr.address |
Contributor
There was a problem hiding this comment.
Love how simple this is 👏🏼
jsjoeio
reviewed
Apr 26, 2022
Comment on lines
+160
to
+168
| it("should construct URL with an IPv4 address", async () => { | ||
| mockServer.address = () => ({ address: "1.2.3.4", port: 5678, family: "IPv4" }) | ||
| const address = ensureAddress(mockServer, "http") | ||
| expect(address.toString()).toBe(`http://1.2.3.4:5678/`) | ||
| }) | ||
| it("should construct URL with an IPv6 address", async () => { | ||
| mockServer.address = () => ({ address: "a:b:c:d::1234", port: 5678, family: "IPv6" }) | ||
| const address = ensureAddress(mockServer, "http") | ||
| expect(address.toString()).toBe(`http://[a:b:c:d::1234]:5678/`) |
Contributor
There was a problem hiding this comment.
appreciate you adding more tests as well 👏🏼
jsjoeio
approved these changes
Apr 26, 2022
Contributor
jsjoeio
left a comment
There was a problem hiding this comment.
This looks great to me! Thank you so much 👏🏼
I'll let @code-asher give the final ✅
code-asher
approved these changes
Apr 26, 2022
Codecov Report
@@ Coverage Diff @@
## main #5133 +/- ##
==========================================
+ Coverage 71.73% 71.75% +0.01%
==========================================
Files 30 30
Lines 1684 1685 +1
Branches 374 375 +1
==========================================
+ Hits 1208 1209 +1
Misses 407 407
Partials 69 69
Continue to review full report at Codecov.
|
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.
Wrap IPv6 addresses in square brackets for URL in ensureAddress.
Fixes #1582 (regression)
Thanks ;-)