Unanswered question

Variable extractor Custom decoder?

Dear Support,

I'm referring to a similar question and that is the Custom decoder. The answer you gave is using the javascript decodeURIComponent() function but when I do use it and click apply I do not get the expected decoding but the same string.

I tried to add to the extracted value at the end .toString.

Fact is that when I'm using a JavaScript outside the Variable Extractor with the same function decodeURIComponent() the conversion works.

The extraction value is vqT1LgBwL5udbWWqafjgBA\u00253D\u00253DTAG0 and the expected should be vqT1LgBwL5udbWWqafjgBA==TAG0.

I still use Neoload 7.3.

Any idea?

Thx

Goran M.
Goran M.

Goran M.

Level
0
24 / 100
points

Answers

Goran M.
Goran M.

Goran M.

Level
0
24 / 100
points

Dear Support,

Here the solution:
function decode(encodedValue) {
const searchValue ="\\u0025";
const replaceWith = '%';

var decodedValue = decodeURIComponent(encodedValue.split(searchValue).join(replaceWith));

return decodedValue;
}

Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team

does this work?
var value=value.replace(new RegExp("\\u0025",'g'),"%")

Goran M.
Goran M.

Goran M.

Level
0
24 / 100
points

Dear Neil W.,

I tried your proposal but it does not work. Instead this works :
var decodedValue = encodedValue.replace(/\\u0025/g,'%');

so the optimized code would look like this:
function decode(encodedValue) {

var decodedValue = decodeURIComponent(encodedValue.replace(/\\u0025/g,'%'));

return decodedValue;
}

Thanks.