Answer the question
In order to leave comments, you need to log in
Route for Cyrillic in Express?
I'm trying to make the router skip expressions, with letters and symbols, like a-zA-Z0-9А-Яа-я_
. How do I do it:
rootApp.all(/\+(\w+|\p{L}+)/, function (req, res, next) {
res.cookie("referer", req.params[0]);
res.send(req.params);
});
GET /+А - 404 NOT FOUND
GET /+ref - {"0":"ref"}
GET /+ref_123ру_ - {"0":"ref_123"}
Answer the question
In order to leave comments, you need to log in
Finally did this:
rootApp.all(/\+(\S+)/, function (req, res, next) {
var decodedPath = decodeURIComponent(req.path),
regexp = /\+[a-zA-Z0-9А-Яа-я_]+/;
var executed = regexp.exec(decodedPath);
if (executed != null) {
var parsed = executed[0].slice(1);
res.cookie("referer", parsed);
res.send(parsed);
}
else next();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question