I need to reload the page location after updating the param values, it wouldn't have been difficult if the params were always in a particular order, but they are not.
So if there was a set pattern, I could target them via regex match, so for example for a URL: http://www.example.html?sf_id=15040&15041.survey=form&variation=25002_1
I was targeting it like this:
window.location.replace( window.location.href.replace( sf_id=\d+&\d+\.survey=form&variation=, 'sf_id=460&460.survey=form&variation=25002_2' ) );
But now the param occurence is random, so these are all valid URLs:
http://www.example.html?15041.survey=form&sf_id=15040&variation=25002_1
http://www.example.html?variation=25002_1&sf_id=15040&15041.survey=form
http://www.example.html?param1=value1&variation=25002_1&sf_id=15040¶m2=value2&15041.survey=form
I know I can still right if/else if statements, but I don't think thats the right way, since there is no specif pattern.
Any help is appreciated! Thank you.