fix(cdn): refer file name from pathname instead of full url

This commit is contained in:
2026-03-19 01:40:41 +07:00 Unverified
parent 7d29a5d5dd
commit 7ab308c038
+3 -1
View File
@@ -17,7 +17,9 @@ export async function fetchToCdn(urls: string[]) {
res.headers
.get("Content-Disposition")
?.match(/^attachment;.*filename="([a-zA-Z0-9-_ .]+)"/)?.[1] ||
res.url.match(/\/([a-zA-Z0-9-_ .]+)$/)?.[1] ||
decodeURIComponent(new URL(res.url).pathname).match(
/\/([a-zA-Z0-9-_ .]+)$/,
)?.[1] ||
`file.${res.headers.get("Content-Type")?.split("/")[1] || "dat"}`,
);
}