function parseQuery(input) {
const params = new URLSearchParams(input);
const result = {};
for (const [key, value] of params.entries()) {
result[key] = value;
}
return result;
}
const input = "code=0&message=OK&transId=XXXX-XXXX-XXXX&redirect=https%3A%2F%2Fpay1.comgate.cz%2Finit%3Fid%3DXXXX-XXXX-XXXX";
const map = parseQuery(input);
console.log("Code:\n " + map["code"]);
console.log("Message:\n " + map["message"]);
console.log("TransId:\n " + map["transId"]);
console.log("Redirect:\n " + map["redirect"]);