mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-30 22:41:47 -05:00
11 lines
438 B
JavaScript
11 lines
438 B
JavaScript
// Normalizes, decomposes, and lowercases a utf-8 string
|
|
exports.canonicalize = displayname => displayname.normalize('NFKD').toLowerCase();
|
|
|
|
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);
|
|
next();
|
|
}; |