Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/naver6376040bb3efd1c12d3560ee3aef78c7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
naver-site-verification: naver6376040bb3efd1c12d3560ee3aef78c7.html
17 changes: 16 additions & 1 deletion src/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ describe("invite preview proxy indexing contract", () => {
it.each([
"Discordbot/2.0",
"KAKAOTALK-SCRAP/1.0",
"facebookexternalhit/1.1; kakaotalk-scrap/1.0; +https://devtalk.kakao.com/t/scrap/33984",
"Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)",
"facebookexternalhit/1.1",
"Twitterbot/1.0",
"LinkedInBot/1.0",
"TelegramBot (like TwitterBot)",
"WhatsApp/2.23",
"Line/13.0",
"line-poker/1.0",
"facebookexternalhit/1.1;line-poker/1.0",
])("rewrites supported social preview UA %s with noindex headers", async (ua) => {
const response = await proxy(inviteRequest(ua));

Expand All @@ -62,6 +64,19 @@ describe("invite preview proxy indexing contract", () => {
expect(response.headers.get("x-middleware-next")).toBe("1");
expect(verifySessionWithOptionalRefresh).toHaveBeenCalledOnce();
});

it.each([
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 KAKAOTALK 10.8.0",
"Mozilla/5.0 (Linux; Android 14; SM-S918N Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.82 Mobile Safari/537.36;KAKAOTALK 2410800",
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Safari Line/14.8.0",
"Mozilla/5.0 (Linux; Android 14; SM-S918N Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.82 Mobile Safari/537.36 Line/14.8.0/IAB",
])("serves the app page to in-app browser UA %s", async (ua) => {
const response = await proxy(inviteRequest(ua));

expect(response.headers.get("x-middleware-rewrite")).toBeNull();
expect(response.headers.get("x-middleware-next")).toBe("1");
expect(verifySessionWithOptionalRefresh).toHaveBeenCalledOnce();
});
});

describe("protected route redirect indexing contract", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { verifySessionWithOptionalRefresh } from "@/lib/auth-server";
import { isProtectedAppPath } from "@/lib/auth-session";

const LINK_PREVIEW_BOT_UA =
/facebookexternalhit|kakaotalk|twitterbot|slackbot|discordbot|linkedinbot|telegrambot|whatsapp|(?:^|[\s;(])line(?:\/|[\s;)])/i;
/facebookexternalhit|kakaotalk-scrap|line-poker|twitterbot|slackbot|discordbot|linkedinbot|telegrambot|whatsapp/i;

function isInvitePreviewRequest(request: NextRequest): boolean {
const { pathname } = request.nextUrl;
Expand Down
Loading