Handle URLs with weird characters
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
|
||||
export async function onRequestDelete(context: RequestContext) {
|
||||
const path = context.params.id;
|
||||
const path = decodeURIComponent(context.params.id as string);
|
||||
|
||||
if (typeof path !== "string") return jsonError("Invalid path", 400);
|
||||
|
||||
@ -42,7 +42,11 @@ export async function onRequestPatch(context: RequestContext) {
|
||||
await context.env.D1.prepare(
|
||||
"UPDATE short_links SET path = ? WHERE path = ? AND user = ?;",
|
||||
)
|
||||
.bind(path, context.params.id, context.data.current_user.id)
|
||||
.bind(
|
||||
path,
|
||||
decodeURIComponent(context.params.id as string),
|
||||
context.data.current_user.id,
|
||||
)
|
||||
.run();
|
||||
|
||||
return new Response(null, {
|
Reference in New Issue
Block a user