Added underscores and dashes to usernames

This commit is contained in:
rainbow napkin 2025-05-02 03:47:46 -04:00
parent 23ceb74883
commit d3aa4b8274
3 changed files with 17 additions and 5 deletions

View file

@ -25,9 +25,19 @@ module.exports.user = function(field = 'user'){
[field]: { [field]: {
escape: true, escape: true,
trim: true, trim: true,
isAlphanumeric: { //Caution: Nerd Rant
errorMessage: "Usernames must be alphanumeric." //isAlphanumerics only takes locale for the option flag in schemas for some reason...
matches: {
//See this is the shit I'm talking about, WHY IS THIS CALLED OPTIONS? IT SHOULD BE PATTERN
//OPTIONS IS SUPPOSED TO BE AN OBJECT THAT PASSES EXTRA VALUES THATS LITERALLY HOW EVERYTHING ELSE IN THIS FUCKING LIBRARY WORKS
//WHO FUCKING WROTE THIS SHIT!?!?!?!?!
//HOW IS THIS ACCEPTED ON ONE OF THE MOST WIDELY USED VALIDATION LIBRARIES ON THE WEB!??!?!?!!?
//IT'S NOT EVEN FUCKING DOCUMENTED ANYWHERE!!!!!!!!!!!!
//WEBDEVS, GET YOUR FUCKING SHIT TOGETHER, FUCK!
options: [/^[A-Za-z0-9-_]+$/],
errorMessage: "Usernames can only contain numbers, letters, underscores, and dashes."
}, },
//matches: /^[A-Za-z0-9-_]+$/,
isLength: { isLength: {
options: { options: {
min: 1, min: 1,

View file

@ -165,6 +165,7 @@ p.panel-head-element{
.chat-entry-username{ .chat-entry-username{
margin: auto 0.2em auto 0; margin: auto 0.2em auto 0;
text-wrap: nowrap;
} }
.chat-entry-body{ .chat-entry-body{
@ -203,6 +204,7 @@ span.user-entry{
font-size: 1em; font-size: 1em;
width: fit-content; width: fit-content;
user-select: none; user-select: none;
text-wrap: nowrap;
} }
.whisper{ .whisper{

View file

@ -73,11 +73,11 @@ class chatPostprocessor{
//Create an empty array to hold the body //Create an empty array to hold the body
this.messageArray = []; this.messageArray = [];
//Escape any sanatized char codes as we use .textContent for double-safety, and to prevent splitting of char codes //Unescape any sanatized char codes as we use .textContent for double-safety, and to prevent splitting of char codes
//Split string by word-boundries on words and non-word boundries around whitespace, with negative lookaheads to exclude file seperators so we don't split link placeholders //Split string by word-boundries on words and non-word boundries around whitespace, with negative lookaheads to exclude file seperators so we don't split link placeholders, and dashes so we dont split usernames and other things
//Also split by any invisble whitespace as a crutch to handle mushed links/emotes //Also split by any invisble whitespace as a crutch to handle mushed links/emotes
//If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet. //If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet.
const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!␜)(?=\w)\b|(?<=\w)\b|(?=\s)\B|(?<=\s)\B|/g); const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!-)(?<!␜)(?=\w)\b|(?!-)(?<=\w)\b|(?=\s)\B|(?<=\s)\B|/g);
//for each word in the splitstring //for each word in the splitstring
splitString.forEach((string) => { splitString.forEach((string) => {