Returned null in case of empty cookie value#196
Conversation
|
Thanks for the contribution! Unfortunately we can't verify the commit author(s): viralsinha <v***@p***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated. |
|
Hi @vsin12, would you be able to update the PR with a test? |
|
@ruoho : Sorry, but I didn't get you ? Do you want me to give a scenario while it was breaking or you want me to write a test to check my pr ? |
awaterma
left a comment
There was a problem hiding this comment.
You wrote: Note: Either this fix, or CookieJar constructor needs to take SetCookieOptions too, as ignoreError is part of SetCookieOptions interface
ignoreError doesn't apply to storage: ignoreError - boolean - default false - silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option -- so I'm not sure we need to do any more here, in terms of implementation. We might want to start a project to review ignoreError and its applications --- it might be better to have that apply globally, but we'd have to think that through.
In terms of this P/R; I think I'd like to see the change use validators, as suggested, and then have a simple unit test added that demonstrates the use-case (an empty cookie).
Co-authored-by: Andrew Waterman <awaterma@awaterma.net>
|
I think we still need a unit test for this fix. :) |
|
@vsin12 can you change this PR to allow edits from maintainers? I have a few changes I would like to push to this PR. |
Done. |
awaterma
left a comment
There was a problem hiding this comment.
I'll discuss this today; I think we want to add a suggestion to return an error when presented with an empty cookie.
| if(!validators.isNonEmptyString(cookie) && !validators.isObject(cookie) && ( cookie instanceof String && cookie.length == 0)) { | ||
| return cb(null); | ||
| } | ||
|
|
There was a problem hiding this comment.
Just looked at this in context, and I think this is fine. Will discuss today.
There was a problem hiding this comment.
Please see comment below; I think we may want an Error here.
| this.callback | ||
| ); | ||
| }, | ||
| "results in a error being returned because of missing parameters": function(err, cookies) { |
There was a problem hiding this comment.
We don't actually return an error, we are invoking the callback with a Null here. Should we invoke the CB with an Error()?
awaterma
left a comment
There was a problem hiding this comment.
Approved. We may want to add error checking/throwing at some point, but that's probably in a major release.
Note: Either this fix, or CookieJar constructor needs to take SetCookieOptions too, as ignoreError is part of SetCookieOptions interface