Skip to content

Commit

Permalink
Merge pull request #22
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
iugmali authored Mar 28, 2024
2 parents f7fbddc + 27979d7 commit 9608540
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion http-client.http
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ POST {{HostAddress}}/checkuserexists
Content-Type: application/json

{
"username": "testuser"
"username": "iugmali"
}
7 changes: 5 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createServer } from 'node:http';
import { Server } from "socket.io";

import { engine } from "express-handlebars";
import {censorWord, FilteredWord} from "./lib/util.js";
import {censorWord} from "./lib/util.js";

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -74,7 +74,10 @@ app.get('/', (req, res) => {

app.post('/checkuserexists', (req, res) => {
const { username } = req.body;
const userExists = Array.from(users).find(user => user.username === username);
const userExists = Array.from(users).find(user => {
const regex = new RegExp(`^${username}$`, 'i');
return regex.test(user.username);
});
if (userExists) {
res.status(400).send();
} else {
Expand Down

0 comments on commit 9608540

Please sign in to comment.