-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(buildSrcSet): ensure operation is idempotent #167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @ericdeansanchez! Only a few small things, overall looks great
No change needed and it's not a big thing, but we don't usually include the changes to |
Also it looks like you're going to need to rebase onto main before merging to keep the history clean 😄 |
Thanks for the great feedback! I think what happened with |
The purpose of this PR is to ensure the buildSrcSet operation is idempotent. Prior to this PR, code modified the input-parameters, params, causing identical calls to buildSrcSet to produce different results. Now, the input params are copied into a new queryParams object and this object is passed to callers requiring params. A test has been written to show that the behavior has changed from the behavior detailed in issue #158––the input params object remains unchanged after calling buildSrcSet and that calling buildSrcSet multiple times produces the same result (given the same inputs). I also ripgrep'd through the repo with `rg 'params.[:alpha:]'` and with `rg 'params\['` to ensure params is never mutated (i.e. it never appears on the left hand side of any expression). Closes #158
1ae3a79
to
a89e6ed
Compare
I'm closing this PR in favor of In the above PR, I tried to use git to clean up some commits, but there were a couple casualty-commits (that were undone unfortunately 🙃. |
The purpose of this PR is to ensure the
buildSrcSet
operation isidempotent. Prior to this PR, code modified the input-parameters,
params
, causing identical calls tobuildSrcSet
to produce differentresults.
Now, the input
params
are copied into a newqueryParams
object andthis object is passed to callers requiring
params
. A test has beenwritten to show that the behavior has changed from the behavior detailed
in issue #158––the input
params
object remains unchanged after callingbuildSrcSet
and that callingbuildSrcSet
multiple times producesthe same result (given the same inputs).
I also ripgrep'd through the repo with
rg 'params.[:alpha:]'
and withrg 'params\['
to ensureparams
is never mutated (i.e. it neverappears on the left hand side of any expression).
Closes #158