You could build out manual query string parsers and constructors, an example would be like:
function parseQuery(qstr){ var query = {}; var a = qstr.split('&'); //take the passed query string and split it on &, creating an array of each value for (var i in a) { //iterate the array of values var b = a[i].split('='); //separate the key and value pair query[decodeURIComponent(b[0])] = decodeURIComponent(b[1]); //call decodeURIComponent to sanitize the query string } return query; //returned the parsed query string object } function buildQuery(obj){ var str = []; for(var p in obj) //iterate the query object if (obj.hasOwnProperty(p)) { //check if the object has the propery name we're iterating str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); //push the encoded key value pair from the object into the string array } return str.join("&"); //take the array of key value pairs and join them on & }
Then below we take the string that you gave, for example:
var $str = 'createimage&t1=1412757517&t2=1412843917&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=0&initialassumedservicestate=0&assumestateretention=yes&includesoftstates=no&host=SCP-3&service=MODIFICATION+TIME+EDR+FILES&backtrack=4&zoom=4';
Now we call the parseQuery function on our string.
var obj = parseQuery($str);
Then we iterate the object which was produced from our parseQuery function
Object.keys(obj).forEach(function(k, i) { switch(k){ case 't1': obj[k] = 'replacedt1'; break; case 'service': obj[k] = 'replacedServices'; break; case 'host': obj[k] = 'replacedHost'; } });
Now the obj variable has the newly updated values. We can rebuild the query using our buildQuery function by passing the object in.
console.log(buildQuery(obj));
Which will produce something like:
createimage=undefined&t1=replacedt1&t2=1412843917&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=0&initialassumedservicestate=0&assumestateretention=yes&includesoftstates=no&host=replacedHost&service=replacedServices&backtrack=4&zoom=4
As usual, the jsFiddle