1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-10 15:48:27 -05:00
shimapan/app/util/canonicalize.js

8 lines
326 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) => {
req.body.username = req.body.displayname ? exports.canonicalize(req.body.displayname) : undefined;
2018-07-25 18:45:38 -04:00
next();
};