Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sandeeppoonia
Copy link

@sandeeppoonia sandeeppoonia commented Dec 16, 2024


This is fix for #594 .

These options are used to create HttpRequest (

let request: HttpRequest = new HttpRequest(options);
) , which is then used to create the rum URL (
const { port, method } = request;
)

@sandeeppoonia sandeeppoonia marked this pull request as draft December 16, 2024 23:24
@sandeeppoonia sandeeppoonia marked this pull request as ready for review December 17, 2024 00:12
@limhjgrace limhjgrace requested review from qhanam, limhjgrace and williazz and removed request for qhanam December 18, 2024 12:48
@@ -114,6 +114,11 @@ export class DataPlaneClient {
const options = {
method: METHOD,
protocol: this.config.endpoint.protocol,
port:
!this.config.endpoint.port ||
Copy link
Contributor

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

@@ -114,6 +114,11 @@ export class DataPlaneClient {
const options = {
method: METHOD,
protocol: this.config.endpoint.protocol,
port:
!this.config.endpoint.port ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there coverage for this line?

Not sure what the point of !this.config.endpoint.port is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

answered above

port:
!this.config.endpoint.port ||
isNaN(parseInt(this.config.endpoint.port, 10))
? undefined
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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.

@limhjgrace limhjgrace requested a review from qhanam December 18, 2024 19:27
Copy link
Member

@qhanam qhanam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm providing @williazz concerns are addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants