@authduo/authduo
Version:
Free User-sovereign Authentication for the World
10 lines • 375 B
JavaScript
/** convert a username into a string that is url friendly and filename friendly */
export function crushUsername(username, maxLength = 24) {
const sanitized = username
.toLowerCase()
.replace(/[^a-z0-9]/gi, "_")
.slice(0, maxLength)
.replace(/^_+|_+$/g, "");
return sanitized || "passport";
}
//# sourceMappingURL=crush-username.js.map