changing path
This commit is contained in:
@@ -7,6 +7,7 @@ import { handleAuth } from "./routes/auth";
|
||||
import { handleDelete } from "./routes/delete";
|
||||
import { handleDownload } from "./routes/download";
|
||||
import { handleUpload } from "./routes/upload";
|
||||
import { KEY_PATTERN } from "./security";
|
||||
import { Storage } from "./storage";
|
||||
|
||||
const cfg = loadConfig();
|
||||
@@ -113,6 +114,19 @@ async function route(req: Request, srv: Server<undefined>): Promise<Response> {
|
||||
return handleDownload(req, storage, path.slice(3), secret);
|
||||
}
|
||||
|
||||
const rootKey = path.slice(1);
|
||||
if (
|
||||
rootKey &&
|
||||
!rootKey.includes("/") &&
|
||||
KEY_PATTERN.test(rootKey) &&
|
||||
(method === "GET" || method === "HEAD")
|
||||
) {
|
||||
if (cfg.rateLimitEnabled && !limiter.check(clientIp(req, srv))) {
|
||||
return jsonError(429, "too many requests");
|
||||
}
|
||||
return handleDownload(req, storage, rootKey, secret);
|
||||
}
|
||||
|
||||
if (path.startsWith("/api/files/") && method === "DELETE") {
|
||||
if (cfg.rateLimitEnabled && !limiter.check(clientIp(req, srv))) {
|
||||
return jsonError(429, "too many requests");
|
||||
|
||||
Reference in New Issue
Block a user