I provide links to external websites in my NodeJS application. These take significant effort to find and I want to track the number of clicks. I prefer to avoid front-end JavaScript as I disable it in my browser. So far I have been using query parameters, such as:
router.get('/redir', async (req, res) => {
let url = req.params.url;
// my own tracking logic
// ...
res.redirect(url);
});
This code fails for links that already contain GET parameters, question marks, and ampersands. I tried this one:
router.get('/redir/:url', async (req, res) => {
let url = req.params.url;
res.redirect(url);
});
and the route is not even called.
How can I track link clicks that already contain ?
and &?