I try to make the router skip expressions, with letters and symbols, such as a-zA-Z0-9А-Яа-я_ . How I do it:
rootApp.all(/\+(\w+|\p{L}+)/, function (req, res, next) { res.cookie("referer", req.params[0]); res.send(req.params); }); But in the end ... GET /+А - 404 NOT FOUND GET /+ref - {"0":"ref"} GET /+ref_123ру_ - {"0":"ref_123"} How to make the parser skip the Cyrillic alphabet?
UPDATE : It turns out that the link is encoded by URL characters. Even if you decode it, still the parsing does not work.
rootApp.all(/\+(\S)/, function (req, res, next) { var decodedPath = decodeURIComponent(req.path), regexp = /\+(\w+|\p{IsCyrillic}+|\p{L}+)/; console.log(decodedPath); if (regexp.test(decodedPath)) { var parsed = regexp.exec(decodedPath); console.log("Parsed String: ", parsed); res.cookie("referer", parsed[1]); res.send(parsed); } else next(); }); Console
/+ref_123ру_ Parsed String: [ '+ref_123', 'ref_123', index: 1, input: '/+ref_123ру_' ]
\p{IsCyrillic}not supported by RegExp. Like all other Unicode classes starting with\p. - Wiktor Stribiżew