MCPcopy Create free account
hub / github.com/dailydotdev/apps / getMarkdownResponse

Function getMarkdownResponse

packages/webapp/proxy.ts:47–71  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

45};
46
47const getMarkdownResponse = (req: NextRequest): NextResponse => {
48 const { pathname } = req.nextUrl;
49
50 if (!pathname.startsWith(POSTS_PREFIX)) {
51 return NextResponse.next();
52 }
53
54 const id = pathname.slice(POSTS_PREFIX.length);
55
56 // `.md` URLs are handled by the beforeFiles rewrite, which runs after
57 // proxy. Rewriting here too would pass the id along with its suffix.
58 if (
59 !id ||
60 id.endsWith('.md') ||
61 RESERVED_POST_SLUGS.includes(id) ||
62 !acceptsMarkdown(req.headers.get('accept'))
63 ) {
64 return NextResponse.next();
65 }
66
67 const url = req.nextUrl.clone();
68 url.pathname = `${POST_MARKDOWN_PATH}/${id}`;
69
70 return NextResponse.rewrite(url);
71};
72
73const handleMarkdownRequest = async (
74 req: NextRequest,

Callers 1

handleMarkdownRequestFunction · 0.85

Calls 2

acceptsMarkdownFunction · 0.90
nextMethod · 0.65

Tested by

no test coverage detected