1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-14 08:49:51 -05:00
shimapan/app/util/canonicalize.js

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();
};