I am writing a simple Azure Function app that should receive a string containing HTML markup remove the HTML tags and return the "sanitized" text.
The code would be really simple, like
module.exports = async function (context, req) {
if (req.body) {
context.res = {
body: req.body.replace(... something)
};
}
};
As far as I can see on SO, using RegEx to do this is a big NO-GO, but the other solutions I can find to this are all based on the DOM (working on the document
object, like adding a DIV with the req.body
contents in it and getting the clean text from that.
But in my Azure function, the DOM is not available to me (since there is no browser executing the request.
So what are my options?