mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix file:// replace
This commit is contained in:
1 file changed
+8
-19
@@ -397,28 +397,17 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
|||||||
@query('pjax', Types.Boolean)
|
@query('pjax', Types.Boolean)
|
||||||
async get(...args: any[]) {
|
async get(...args: any[]) {
|
||||||
// Navigate to current additional file download
|
// Navigate to current additional file download
|
||||||
// e.g.  will navigate to 
|
// e.g.  will navigate to 
|
||||||
if (!this.request.json || args[2]) {
|
if (!this.request.json || args[2]) {
|
||||||
if (args[1]) {
|
|
||||||
this.response.body.pdoc.content = this.response.body.pdoc.content
|
this.response.body.pdoc.content = this.response.body.pdoc.content
|
||||||
.replace(/\(file:\/\/(.+?)\)/g, (str) => {
|
.replace(/file:\/\/([^ \n)\\"]+?)/g, (str) => {
|
||||||
const info = str.match(/\(file:\/\/(.+?)\)/);
|
const info = str.match(/\]\(file:\/\/(.+?)\)/);
|
||||||
return `(./${this.pdoc.docId}/file/${info[1]}${info[1].includes('?') ? '&' : '?'}tid=${args[1]})`;
|
const fileinfo = info[1];
|
||||||
})
|
const filename = fileinfo.split('?')[0]; // remove querystring
|
||||||
.replace(/="file:\/\/(.+?)"/g, (str) => {
|
if (!this.pdoc.additional_file?.find((i) => i.name === filename)) return str;
|
||||||
const info = str.match(/="file:\/\/(.+?)"/);
|
if (!args[1]) return `./${this.pdoc.docId}/file/${fileinfo}`;
|
||||||
return `="./${this.pdoc.docId}/file/${info[1]}${info[1].includes('?') ? '&' : '?'}tid=${args[1]}"`;
|
return `./${this.pdoc.docId}/file/${fileinfo}${fileinfo.includes('?') ? '&' : '?'}tid=${args[1]}`;
|
||||||
})
|
|
||||||
.replace(/=\\"file:\/\/(.+?)\\"/g, (str) => {
|
|
||||||
const info = str.match(/=\\"file:\/\/(.+?)\\"/);
|
|
||||||
return `=\\"./${this.pdoc.docId}/file/${info[1]}${info[1].includes('?') ? '&' : '?'}tid=${args[1]}\\"`;
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.response.body.pdoc.content = this.response.body.pdoc.content
|
|
||||||
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`)
|
|
||||||
.replace(/="file:\/\//g, `="./${this.pdoc.docId}/file/`)
|
|
||||||
.replace(/=\\"file:\/\//g, `=\\"${this.pdoc.docId}/file/`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.response.body.page_name = this.tdoc
|
this.response.body.page_name = this.tdoc
|
||||||
? this.tdoc.rule === 'homework'
|
? this.tdoc.rule === 'homework'
|
||||||
|
|||||||
Reference in new issue
Block a user