Skip to content

Commit

Permalink
fixbug:自定义下划线匹配
Browse files Browse the repository at this point in the history
  • Loading branch information
ling-drag0n authored Dec 28, 2024
1 parent 24b85e6 commit 9bef303
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7729,7 +7729,7 @@ export default {
}

// 删除分享
if (url.pathname.match(/^\/api\/admin\/(paste|file)\/[a-zA-Z0-9]+$/)) {
if (url.pathname.match(/^\/api\/admin\/(paste|file)\/[a-zA-Z0-9-_]+$/)) {
if (request.method !== "DELETE") {
return new Response("Method not allowed", { status: 405 });
}
Expand Down Expand Up @@ -8152,18 +8152,18 @@ export default {
}

// 重定向 API 直接访问到分享页面
if (url.pathname.match(/^\/paste\/[a-zA-Z0-9]+$/)) {
if (url.pathname.match(/^\/paste\/[a-zA-Z0-9-_]+$/)) {
const id = url.pathname.split("/").pop();
return Response.redirect(`${url.origin}/share/paste/${id}`, 301);
}

if (url.pathname.match(/^\/file\/[a-zA-Z0-9]+$/)) {
if (url.pathname.match(/^\/file\/[a-zA-Z0-9-_]+$/)) {
const id = url.pathname.split("/").pop();
return Response.redirect(`${url.origin}/share/file/${id}`, 301);
}

// 添加直接下载路由
if (url.pathname.match(/^\/download\/[a-zA-Z0-9]+$/)) {
if (url.pathname.match(/^\/download\/[a-zA-Z0-9-_]+$/)) {
const id = url.pathname.split("/").pop();
const modifiedRequest = new Request(`${url.origin}/api/file/${id}?download=true`, {
method: "GET",
Expand Down

0 comments on commit 9bef303

Please sign in to comment.