Skip to content

Commit

Permalink
backendL api: users: fix empty and undefined string check
Browse files Browse the repository at this point in the history
Empty strings are falsey for JS, so explicitly check for undefined
  • Loading branch information
ericswpark committed Apr 18, 2024
1 parent 8720045 commit 8337d51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/src/app/api/v0/users/about_me_bio/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function PATCH(request: NextRequest) {
const user_id = await checkUserToken(authToken);
if (user_id instanceof NextResponse) return user_id;

let about_me_bio;
let about_me_bio: string;
try {
const data = await request.json();
about_me_bio = data.about_me_bio;
Expand All @@ -36,7 +36,7 @@ export async function PATCH(request: NextRequest) {
});
}

if (!about_me_bio) {
if (typeof about_me_bio != "string") {
return construct_development_api_response({
message: `You're trying to update the about me bio, but didn't supply the new about me bio as a parameter.`,
status_code: 400,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app/api/v0/users/social_url/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function PATCH(request: NextRequest) {
const user_id = await checkUserToken(authToken);
if (user_id instanceof NextResponse) return user_id;

let social_url;
let social_url: string;
try {
const data = await request.json();
social_url = data.social_url;
Expand Down

0 comments on commit 8337d51

Please sign in to comment.