Add new config use_path_based_img_url

Fix parseBitInt
This commit is contained in:
2024-06-02 13:33:46 +08:00
parent 329a91e9c0
commit 0ea6da38e4
8 changed files with 119 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ import type { EhFileExtend } from "../../../server/files.ts";
import { User, UserPermission } from "../../../db.ts";
import { SortableURLSearchParams } from "../../../server/SortableURLSearchParams.ts";
import { isNumNaN, parseBigInt } from "../../../utils.ts";
import { extname } from "@std/path";
export const handler: Handlers = {
async GET(req, ctx) {
@@ -77,6 +78,12 @@ export const handler: Handlers = {
),
);
if (verify === null) {
if (m.cfg.use_path_based_img_url) {
const ext = extname(f.path);
return Response.redirect(
`${get_host(req)}/file/${tverify}/${f.id}${ext}`,
);
}
const b = new URLSearchParams();
b.append("verify", tverify);
return Response.redirect(

View File

@@ -167,6 +167,11 @@ export const handler: Handlers = {
);
const b = new URLSearchParams(bs.toString());
b.append("verify", tverify);
if (m.cfg.use_path_based_img_url) {
return Response.redirect(
`${get_host(req)}/thumbnail/${b}/${f.id}.jpg`,
);
}
return Response.redirect(
`${get_host(req)}/thumbnail/${f.id}?${b}`,
);