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

don't send proxy-authorization header if username and password on URL are empty #22

Merged
merged 1 commit into from
Jun 28, 2021

Conversation

mojavelinux
Copy link
Contributor

resolves #18

@mojavelinux
Copy link
Contributor Author

mojavelinux commented May 23, 2021

The WHATWG URL object always sets the username and password to a string (https://nodejs.org/api/url.html#url_url_username and https://nodejs.org/api/url.html#url_url_password). So if the component part is missing from the URL, the value will be empty string. We can simplify the check to a falsy check (since empty string is falsy). This has the benefit of catching other kinds of empty values (null and undefined) if the user of the API passes in a custom object.

I also modified the logic so that the authorization header is sent if either username or password is set since it's viable to only pass one of them.

Let me know if you need me to update the code in any way. I'm willing to make whatever changes you need me to make to get this PR approved.

Copy link
Owner

@delvedor delvedor left a comment

Choose a reason for hiding this comment

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

Great catch!

@delvedor delvedor merged commit a703881 into delvedor:master Jun 28, 2021
@mojavelinux
Copy link
Contributor Author

Thanks!

@mojavelinux mojavelinux deleted the issue-18-no-auth-if-empty branch June 28, 2021 17:56
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.

Don't send proxy-authorization header with empty username & password.
2 participants