diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 156365f54..7b344ee5b 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.15.12", + "version": "2.15.13", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 959f5bd3b..5a586c9f8 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -194,8 +194,13 @@ export class ProblemDetailHandler extends ProblemHandler { async get(..._args: any[]) { // Navigate to current additional file download // e.g. ![img](a.jpg) will navigate to ![img](./pid/file/a.jpg) - this.response.body.pdoc.content = this.response.body.pdoc.content - .replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`); + if (typeof this.response.body.pdoc.content === 'string') { + this.response.body.pdoc.content = this.response.body.pdoc.content + .replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`); + } else { + this.response.body.pdoc.content = JSON.parse(JSON.stringify(this.response.body.pdoc.content) + .replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`)); + } } @param('pid', Types.UnsignedInt)