From 35c4a72388a1d8495a7beba4cd10a70612843745 Mon Sep 17 00:00:00 2001 From: Ankit Dash Date: Wed, 13 Nov 2024 22:06:03 +0530 Subject: [PATCH] fix sonarcloud errors --- apps/studio/src/app/api/v1/crawler/route.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/studio/src/app/api/v1/crawler/route.tsx b/apps/studio/src/app/api/v1/crawler/route.tsx index 2678458ca..8bfaf5f88 100644 --- a/apps/studio/src/app/api/v1/crawler/route.tsx +++ b/apps/studio/src/app/api/v1/crawler/route.tsx @@ -8,6 +8,7 @@ export async function GET(request: NextRequest) { const Base64searchParams = request.nextUrl.searchParams.get('base64'); const URLsearchParams = request.nextUrl.searchParams.get('url'); + const invalidResponse = new NextResponse('Not a valid URL', { status: 500 }); try { if (!Base64searchParams && !URLsearchParams) return new NextResponse(null, { status: 200 }); let info: DocumentInfo | null = null; @@ -23,10 +24,10 @@ export async function GET(request: NextRequest) { if (response.status === 200) { info = await parseURL(response.data); } else { - return new NextResponse('Not a valid URL', { status: 500 }); + return invalidResponse; } } catch (error) { - return new NextResponse('Not a valid URL', { status: 500 }); + return invalidResponse; } } @@ -90,7 +91,7 @@ export async function GET(request: NextRequest) { `; - console.log(crawlerInfo); + return new NextResponse(crawlerInfo, { status: 200, headers: { @@ -98,6 +99,7 @@ export async function GET(request: NextRequest) { }, }); } catch (err) { - return new NextResponse('Not a valid URL', { status: 500 }); + return invalidResponse; } } +