Skip to content

Commit

Permalink
rss: set content-type for xml better
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Nov 5, 2023
1 parent 6a22603 commit 73ec772
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pages/api/social/comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const comments = await getRemoteCommentsOnLocalContent(req.query.resource as string);

let renderedTree =
`<?xml version='1.0' encoding='UTF-8'?>` +
`<?xml version="1.0" encoding="UTF-8"?>` +
renderToString(<Comments contentOwner={contentOwner} comments={comments} req={req} />);
// XXX(mime): in the feeds I have some attributes that are `ref`. However, ref isn't allowed in React,
// so in the DOM they are `refXXX`. Return them to normal here, sigh.
renderedTree = renderedTree.replace(/refXXX="([^"]+)"/g, 'ref="$1"');

res.setHeader('Content-Type', 'xml');
res.setHeader('Content-Type', 'application/xml');
res.send(renderedTree);
}

Expand Down
2 changes: 1 addition & 1 deletion pages/api/social/feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// so in the DOM they are `refXXX`. Return them to normal here, sigh.
renderedTree = renderedTree.replace(/refXXX="([^"]+)"/g, 'ref="$1"');

res.setHeader('Content-Type', 'xml');
res.setHeader('Content-Type', 'application/xml');
res.send(renderedTree);
}

Expand Down
2 changes: 1 addition & 1 deletion pages/api/social/foaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)

res.setHeader('Content-Type', 'application/xrd+xml');
res.send(
`<?xml version='1.0' encoding='UTF-8'?>` +
`<?xml version="1.0' encoding='UTF-8"?>` +
renderToString(<FOAF req={req} user={user} followers={followers} following={following} />)
);
}
Expand Down

1 comment on commit 73ec772

@vercel
Copy link

@vercel vercel bot commented on 73ec772 Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.