Closed mojavelinux closed 3 years ago
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.
Thanks!
resolves #18