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

Creating util function to validate handlers #894

Merged
merged 1 commit into from
Jul 21, 2021
Merged

Creating util function to validate handlers #894

merged 1 commit into from
Jul 21, 2021

Conversation

joaopedrocampos
Copy link
Contributor

Creates a util function to validate handler and adds it on redirect since it was missing.

Also changes the hostname.startsWith('[') for hostname[0] === '[' since it's more performing.

Standardizes invalid handler error messages

Related issue: #893

@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2021

Codecov Report

Merging #894 (e3546d8) into main (ef788ee) will decrease coverage by 0.04%.
The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   99.62%   99.57%   -0.05%     
==========================================
  Files          26       26              
  Lines        2127     2131       +4     
==========================================
+ Hits         2119     2122       +3     
- Misses          8        9       +1     
Impacted Files Coverage Δ
lib/client.js 99.60% <66.66%> (ø)
lib/core/util.js 99.00% <94.11%> (-1.00%) ⬇️
lib/agent.js 98.05% <100.00%> (ø)
lib/core/request.js 98.98% <100.00%> (-0.13%) ⬇️
lib/handler/redirect.js 96.92% <100.00%> (+0.04%) ⬆️
lib/pool.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef788ee...e3546d8. Read the comment docs.

@joaopedrocampos joaopedrocampos mentioned this pull request Jul 20, 2021
@joaopedrocampos
Copy link
Contributor Author

@ronag I created the handler validation function with the same conditions that were on request.js, but there are other places that make a simple validation's of it, e.g:

https://github.com/nodejs/undici/blob/main/lib/client.js#L286

So I don't know if it's ok to follow this approach I did or if it's better to create many "individual validation functions" (does this makes sense?) to use them in these cases

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 0391411 into nodejs:main Jul 21, 2021
@joaopedrocampos joaopedrocampos deleted the create-handler-validator branch July 21, 2021 12:34
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
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.

4 participants