1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-12-04 19:32:20 -05:00
shimapan/app/util/canonicalize.js

11 lines
438 B
JavaScript
Raw Normal View History

2018-07-25 18:45:38 -04:00
// Normalizes, decomposes, and lowercases a utf-8 string
exports.canonicalize = displayname => displayname.normalize('NFKD').toLowerCase();
2018-07-25 18:45:38 -04:00
exports.canonicalizeRequest =
(req, res, next) => {
if (req.body.displayname)
req.body.username = exports.canonicalize(req.body.displayname);
else if (req.body.username)
req.body.username = exports.canonicalize(req.body.username);
2018-07-25 18:45:38 -04:00
next();
};