Skip to content

Commit

Permalink
Merge pull request #3 from helios2003/fixes
Browse files Browse the repository at this point in the history
Addressing comments of the maintainers
  • Loading branch information
helios2003 authored Aug 4, 2024
2 parents 2e4b637 + 4f08a7a commit 665fcf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/studio-next/src/app/api/crawler/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
import parseURL from "@/helpers/parser";
import { DocumentInfo } from "@/types";
import axios from "axios";
import { metadata } from "@/app/page";
import { metadata } from "@/app/page";

export async function GET(request: NextRequest) {
const Base64searchParams = request.nextUrl.searchParams.get('base64');
Expand Down Expand Up @@ -32,7 +32,7 @@ export async function GET(request: NextRequest) {

if (!info) {
const ogImage = "https://raw.githubusercontent.com/asyncapi/studio/master/apps/studio-next/public/img/meta-studio-og-image.jpeg";

const crawlerInfo = `
<!DOCTYPE html>
<html lang="en">
Expand Down
8 changes: 3 additions & 5 deletions apps/studio-next/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ export async function middleware(request: NextRequest) {
const userAgents = crawlers.map(crawler => crawler.pattern);
const requestInfo = userAgent(request);
const res = NextResponse.next();
const documentURL = request.nextUrl.searchParams.get("url");


for (const ua of userAgents) {
if (requestInfo.ua.toLowerCase().includes(ua.toLowerCase())) {

const documentURL = request.nextUrl.searchParams.get("url");
const encodedDocument = request.nextUrl.searchParams.get("base64");

if (!encodedDocument && !documentURL) {
Expand All @@ -25,6 +26,3 @@ export async function middleware(request: NextRequest) {
return res;
}

export const config = {
matcher: ['/:base64', '/:url'],
}

0 comments on commit 665fcf0

Please sign in to comment.