From 56396940fc9e522a241cddf8437a6c9271e6c84e Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 28 May 2022 19:11:19 +0800 Subject: [PATCH] core: fix title check --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/lib/validator.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 87fa720a9..61c9bc623 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.13.11", + "version": "3.13.12", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/lib/validator.ts b/packages/hydrooj/src/lib/validator.ts index ab95ecad0..a28f0fcd2 100644 --- a/packages/hydrooj/src/lib/validator.ts +++ b/packages/hydrooj/src/lib/validator.ts @@ -59,8 +59,8 @@ export function validate(scheme: any, arg: any) { return _validate(scheme, arg, ''); } -export const isTitle = (s) => s && s.length < 64; -export const checkTitle = (s) => { if (!(s && s.length < 64)) throw new ValidationError('title'); else return s; }; +export const isTitle = (s) => typeof s === 'string' && s.trim().length < 64; +export const checkTitle = (s) => { if (!(typeof s === 'string' && s.trim().length < 64)) throw new ValidationError('title'); else return s; }; export const isDomainId = (s) => RE_DOMAINID.test(s); export const checkDomainId = (s) => { if (!isDomainId(s)) throw new ValidationError('domainId'); else return s; }; export const isUid = (s) => RE_UID.test(s);