mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: 自动转换pid
This commit is contained in:
1 parent
af345d78de
commit
9b3ceb82de
4 files changed
+10
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.25.14",
|
||||
"version": "2.25.15",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -15,7 +15,7 @@ import { PERM } from '../model/builtin';
|
||||
import {
|
||||
Route, Handler, Types, post,
|
||||
} from '../service/server';
|
||||
import { isPid } from '../lib/validator';
|
||||
import { isPid, parsePid } from '../lib/validator';
|
||||
import download from '../lib/download';
|
||||
|
||||
const RE_SYZOJ = /(https?):\/\/([^/]+)\/(problem|p)\/([0-9]+)\/?/i;
|
||||
@@ -221,7 +221,7 @@ class ProblemImportSYZOJHandler extends Handler {
|
||||
}
|
||||
|
||||
@post('url', Types.Content, true)
|
||||
@post('pid', Types.Name, true, isPid)
|
||||
@post('pid', Types.Name, true, isPid, parsePid)
|
||||
@post('hidden', Types.Boolean)
|
||||
@post('prefix', Types.Name, true)
|
||||
@post('start', Types.UnsignedInt, true)
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ProblemDoc, User, RecordDoc, PathComponent, ProblemStatusDoc,
|
||||
} from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { isPid } from '../lib/validator';
|
||||
import { isPid, parsePid as convertPid } from '../lib/validator';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
import { parseConfig } from '../lib/testdataConfig';
|
||||
import * as system from '../model/system';
|
||||
@@ -358,7 +358,7 @@ export class ProblemEditHandler extends ProblemManageHandler {
|
||||
@route('pid', Types.Name, null, parsePid)
|
||||
@post('title', Types.Title)
|
||||
@post('content', Types.Content)
|
||||
@post('pid', Types.Name, isPid, true)
|
||||
@post('pid', Types.Name, isPid, convertPid, true)
|
||||
@post('hidden', Types.Boolean)
|
||||
@post('tag', Types.Content, true, null, parseCategory)
|
||||
async post(
|
||||
@@ -600,7 +600,7 @@ export class ProblemCreateHandler extends Handler {
|
||||
|
||||
@post('title', Types.Title)
|
||||
@post('content', Types.Content)
|
||||
@post('pid', Types.Name, true, isPid)
|
||||
@post('pid', Types.Name, true, isPid, convertPid)
|
||||
@post('hidden', Types.Boolean)
|
||||
@post('tag', Types.Content, true, null, parseCategory)
|
||||
async post(domainId: string, title: string, content: string, pid: string, hidden = false, tag: string[] = []) {
|
||||
|
||||
@@ -81,6 +81,8 @@ export const checkIntro = (s) => { if (!isIntro()) throw new ValidationError('in
|
||||
export const isDescription = (s: any) => s && s.length < 65536;
|
||||
export const checkDescription = (s) => { if (!(s && s.length < 65536)) throw new ValidationError('description'); else return s; };
|
||||
|
||||
export const parsePid = (s) => (Number.isNaN(+s) ? s : `P${s}`);
|
||||
|
||||
global.Hydro.lib.validator = {
|
||||
validate,
|
||||
isTitle,
|
||||
@@ -105,4 +107,6 @@ global.Hydro.lib.validator = {
|
||||
checkIntro,
|
||||
isDescription,
|
||||
checkDescription,
|
||||
|
||||
parsePid,
|
||||
};
|
||||
Reference in new issue
Block a user