core&ui: fix empty pretest input

This commit is contained in:
undefined committed 2023-02-10 21:25:55 +08:00
1 parent f30a39593f
commit 478666bdf5
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -51,9 +51,9 @@ export interface Types {
} }
const basicString = <T = string>(regex?: RegExp, cb?: (i: string) => boolean, convert?: (i: string) => T) => [ const basicString = <T = string>(regex?: RegExp, cb?: (i: string) => boolean, convert?: (i: string) => T) => [
convert || ((v) => v.toString().trim()), convert || ((v) => v.toString()),
(v) => { (v) => {
const res = v.toString().trim(); const res = v.toString();
if (regex && !regex.test(res)) return false; if (regex && !regex.test(res)) return false;
if (cb && !cb(res)) return false; if (cb && !cb(res)) return false;
return !!res.length; return !!res.length;
@@ -40,7 +40,7 @@ const mapDispatchToProps = (dispatch) => ({
const req = request.post(UiContext.postSubmitUrl, { const req = request.post(UiContext.postSubmitUrl, {
lang: props.editorLang, lang: props.editorLang,
code: props.editorCode, code: props.editorCode,
input: props.pretestInput || ' ', input: props.pretestInput,
pretest: true, pretest: true,
}); });
dispatch({ dispatch({