This is test code. I'm not sure why I'm not getting the string returned on line console.log("hasToken : " + hasToken);? I should get it returned after 3 failed attempts. The string without the tokens (var XX) works fine but the string with the token (var X) never returns the string properly. If I step through the code I see the string being passed back but something else happens and I don't know why? The console.log shows undefined for the hasToken value? I see where the string is suppossed to be returned.Test Code Here
var x = "//tokene.secure.adnxs.com/px?randomnumber=[timeSTAMP]&url=[URl]&newvsreturning=[NEWvsRETURNING]";
var xx = '//xwww.googleadservices.com/pagead/conversion/822232847/?label=_7yrCLe91H4Qj46JiAM&guid=ON&script=0';
var regex = new RegExp("/\\[URL\\]|\\[NEWVSRETURNING\\]|\\[RANDOMNUMBER\\]|\\[TIMESTAMP\\]|\\[CACHEBUSTER\\]/", "i");
function validateTokenRemoval(str) {
cnt = 0;
function testTokenRemoved(str) {
if ((regex.test(str))&&(cnt < 2)) {
//if in here it still has tokens
cnt++;
//str = detokenizeTags(imgSrc);
console.log(cnt + " failed : " + str);
testTokenRemoved(str);
} else {
console.log(cnt + " passed : " + str);
return str;
}
};
return testTokenRemoved(str);
};
var hasToken = validateTokenRemoval(x);
var noToken = validateTokenRemoval(xx);
console.log("hasToken : " + hasToken);
console.log("noToken : " + noToken);
