-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use port from endpoint url to create HttpRequestOptions: fix for 594 #595
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,11 @@ export class DataPlaneClient { | |
const options = { | ||
method: METHOD, | ||
protocol: this.config.endpoint.protocol, | ||
port: | ||
!this.config.endpoint.port || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there coverage for this line? Not sure what the point of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. answered above |
||
isNaN(parseInt(this.config.endpoint.port, 10)) | ||
? undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there test coverage for when the port is not a number, and becomes undefined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost all the other tests are for the use-case where port is not set and I have added one where port is set. I cannot add a case for invalid port because URL class does not allow that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added couple of more tests to specifically test when port is not set and validated it against the code without my change. |
||
: parseInt(this.config.endpoint.port, 10), | ||
headers: { | ||
'content-type': contentType, | ||
host: this.config.endpoint.host | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we can simplify lines 117-118. Otherwise, looks great! Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup correct! I was doing a null check but of course parseInt will return NaN in that case so its not required. In fact I will simply use Number instead of parseInt because URL class already does the checks for us and we should just rely on it to do the right thing.