I got a solution, parsing the Delivery's HTML content:
function validateUrlsInHtml(htmlSource) {
logInfo("### Starting URL Valdation process.");
var urlRegex = /href="(http[s]?:\/\/[^"]*)"/gi;
var match;
var foundUrls = [];
var isValid = true;
//Extracting URLs using the regex
logInfo("### Extracting URLs from HTML source.");
while ((match = urlRegex.exec(htmlSource)) !== null) {
foundUrls.push(match[1]);
logInfo("### Found URL: " + match[1]);
}
// Check if no URLs are found
if (foundUrls.length === 0) {
logInfo("### No URLs found. Exiting fn using True");
return true;
}
logInfo("### Validating found URLs against domain criteria.");
// Log and validate each URL
for (var i = 0; i < foundUrls.length; i++) {
var url = foundUrls[i];
logInfo("### Checking URL: " + url);
if (url.indexOf('abc.com') !== -1 && url.indexOf('xyz.com') !== -1) {
logInfo("### Valid URL found: " + url);
} else {
logInfo("### Found URL - different domain: " + url);
logInfo("### Process stopped because of typology rule: Only valid domains.");
isValid = false;
}
}
logInfo("### URL Validation process complete");
return isValid;
}
return validateUrlsInHtml(delivery.content.html.source);
Thanks to Manoj for giving a path to follow.