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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user