`buildSrcSet` mutates `params` argument when building either fluid or fixed-width srcset.
frederickfogerty opened this issue ยท 2 comments
Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
Describe the bug
In the logic used to build the srcset url, the source code assigns extra keys to the "imgix params" object passed to it by the caller.
To Reproduce
An example to illustrate the problem, although other possible combinations will exist.
const Imgix = require("imgix-core-js")
const client = new Imgix({
domain: 'test.imgix.net'
});
const params = {}
const srcsetOptions = { widths: [100] }
const url1 = client.buildSrcSet('', params, srcsetOptions);
const url2 = client.buildSrcSet('', params, srcsetOptions);
console.log(params, url1, url2)
It can clearly be seen in the screenshot above that params has been mutated. This causes the two urls generated to be different even though they were called with the same parameters.
Repro here: https://runkit.com/frederickfogerty/5f3e2c640856920019d6bfd8
Expected behavior
params
and other parameters to not be mutated
Screenshots
If applicable, add screenshots to help explain your problem.
Information:
- imgix-core-js version: 2.3.1
Additional context
I think the entirety of imgix-core-js should be audited for this problem. I have found the following errors in the source code, but there might be more.
https://github.com/imgix/imgix-core-js/blob/main/src/imgix-core-js.js#L111
https://github.com/imgix/imgix-core-js/blob/main/src/imgix-core-js.js#L179
https://github.com/imgix/imgix-core-js/blob/main/src/imgix-core-js.js#L199
https://github.com/imgix/imgix-core-js/blob/main/src/imgix-core-js.js#L202
By the way, I have also experienced this with the .buildURL
method too ๐
๐ This issue has been resolved in version 0.3.0-beta.1 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐