fix(posts): Decode URL-encoded post IDs in API routes

- Add decodeURIComponent() to handle URL-encoded characters in post IDs
- Update like endpoint POST and DELETE handlers to decode rawId parameter
- Update repost endpoint POST and DELETE handlers to decode rawId parameter
- Update post retrieval GET handler to decode rawId parameter
- Fixes issues with special characters (e.g., %3A for colons) in post identifiers
This commit is contained in:
Christomatt
2026-01-26 13:31:23 +01:00
parent 9581fd2810
commit 5d2c05dcbf
3 changed files with 11 additions and 5 deletions
+4 -2
View File
@@ -34,7 +34,8 @@ function extractSwarmPostId(apId: string): string | null {
export async function POST(request: Request, context: RouteContext) {
try {
const user = await requireAuth();
const { id: postId } = await context.params;
const { id: rawId } = await context.params;
const postId = decodeURIComponent(rawId);
const nodeDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost:3000';
if (user.isSuspended || user.isSilenced) {
@@ -210,7 +211,8 @@ export async function POST(request: Request, context: RouteContext) {
export async function DELETE(request: Request, context: RouteContext) {
try {
const user = await requireAuth();
const { id: postId } = await context.params;
const { id: rawId } = await context.params;
const postId = decodeURIComponent(rawId);
const nodeDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost:3000';
if (user.isSuspended || user.isSilenced) {