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

refactor(http): prepare for noUncheckedIndexedAccess #4298

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

gabelluardo
Copy link
Contributor

@gabelluardo gabelluardo commented Feb 9, 2024

Ref: #4040

@iuioiua
Copy link
Collaborator

iuioiua commented Feb 10, 2024

Hi Gabriele, thank you for the PR. PTAL at #4275 (review). It details how these PRs for #4040 should be approached.

@gabelluardo
Copy link
Contributor Author

Hi @iuioiua, thanks for the suggestion, I think I did it better now.

However, I have a doubt about these two functions:

https://github.com/denoland/deno_std/blob/083a2b12ba45381c78dbabfcf06d48e2da27f16b/http/_negotiation/media_type.ts#L54-L69

and

https://github.com/denoland/deno_std/blob/083a2b12ba45381c78dbabfcf06d48e2da27f16b/http/_negotiation/media_type.ts#L71-L86

I tested with unit tests and seems theses two function can be replaced with accept.split(","); and str.split(";").map((p) => p.trim()). Is a test bug or we can remove the for loops?

@iuioiua
Copy link
Collaborator

iuioiua commented Feb 12, 2024

Hi @iuioiua, thanks for the suggestion, I think I did it better now.

However, I have a doubt about these two functions:

https://github.com/denoland/deno_std/blob/083a2b12ba45381c78dbabfcf06d48e2da27f16b/http/_negotiation/media_type.ts#L54-L69

and

https://github.com/denoland/deno_std/blob/083a2b12ba45381c78dbabfcf06d48e2da27f16b/http/_negotiation/media_type.ts#L71-L86

I tested with unit tests and seems theses two function can be replaced with accept.split(","); and str.split(";").map((p) => p.trim()). Is a test bug or we can remove the for loops?

Yeah, you're mostly right. Each of these can be replaced by header.split(delimiter).map((p) => p.trim()). I don't see how quote counting is needed here.

http/_negotiation/encoding.ts Show resolved Hide resolved
http/_negotiation/language.ts Show resolved Hide resolved
http/_negotiation/media_type.ts Show resolved Hide resolved
http/server_test.ts Outdated Show resolved Hide resolved
http/server_test.ts Outdated Show resolved Hide resolved
http/server_test.ts Outdated Show resolved Hide resolved
http/server_test.ts Show resolved Hide resolved
Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

LGTM. @kitsonk, please feel free to review as this code was introduced to the codebase by you.

@iuioiua iuioiua merged commit 73ff70d into denoland:main Feb 15, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants