replace String.random with randomstring

This commit is contained in:
undefined committed 2025-06-30 16:24:35 +08:00
1 parent b18cce3f66
commit 5d7f5fef38
22 files changed
+64 -48

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@ import decodeHTML from 'decode-html';
import xml2js from 'xml2js';
import {
_, BadRequestError, buildContent, Context, FileTooLargeError, fs, Handler, PERM, ProblemConfigFile,
ProblemModel, ProblemType, Schema, SolutionModel, SystemModel, ValidationError, yaml, Zip,
ProblemModel, ProblemType, randomstring, Schema, SolutionModel, SystemModel, ValidationError, yaml, Zip,
} from 'hydrooj';
const knownRemoteMapping = {
@@ -65,7 +65,7 @@ class FpsProblemImportHandler extends Handler {
}
if (p.img?.length) {
for (const img of p.img) {
const filename = String.random(8) + img.src[0].split('/').pop().split('.').pop();
const filename = randomstring(8) + img.src[0].split('/').pop().split('.').pop();
tasks.push(ProblemModel.addAdditionalFile(domainId, pid, filename, Buffer.from(img.base64[0], 'base64')));
content = content.replace(img.src[0], `file://${filename}`);
}