fix(results): encode download filenames (#587)

This commit is contained in:
桌子潔 authored and GitHub committed 2026-08-03 21:21:08 +02:00
1 parent 7157d2398e
commit 15e4046c19
3 files changed
+18 -2

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
export function buildDownloadUrl(webroot: string, outputPath: string, fileName: string): string {
return `${webroot}/download/${outputPath}${encodeURIComponent(fileName)}`;
}
+3 -2
View File
@@ -3,6 +3,7 @@ import { BaseHtml } from "../components/base";
import { Header } from "../components/header";
import db from "../db/db";
import { Filename, Jobs } from "../db/types";
import { buildDownloadUrl } from "../helpers/buildDownloadUrl";
import { ALLOW_UNAUTHENTICATED, WEBROOT } from "../helpers/env";
import { DownloadIcon } from "../icons/download";
import { DeleteIcon } from "../icons/delete";
@@ -107,7 +108,7 @@ function ResultsArticle({
text-accent-500 underline
hover:text-accent-400
`}
href={`${WEBROOT}/download/${outputPath}${file.output_file_name}`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
>
<EyeIcon />
</a>
@@ -116,7 +117,7 @@ function ResultsArticle({
text-accent-500 underline
hover:text-accent-400
`}
href={`${WEBROOT}/download/${outputPath}${file.output_file_name}`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
download={file.output_file_name}
>
<DownloadIcon />