Skip to content

Commit

Permalink
fix sonarcloud errors
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Nov 13, 2024
1 parent 67dc055 commit 35c4a72
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apps/studio/src/app/api/v1/crawler/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -90,14 +91,15 @@ export async function GET(request: NextRequest) {
</head>
</html>
`;
console.log(crawlerInfo);

return new NextResponse(crawlerInfo, {
status: 200,
headers: {
'Content-Type': 'text/html',
},
});
} catch (err) {
return new NextResponse('Not a valid URL', { status: 500 });
return invalidResponse;
}
}

0 comments on commit 35c4a72

Please sign in to comment.