stop saving url in paste

This commit is contained in:
Chris W 2023-10-22 13:16:34 -06:00
parent a4156f82d8
commit 29ed8c1073
1 changed files with 7 additions and 3 deletions

View File

@ -137,7 +137,6 @@ export const POST: RequestHandler = async ({ request }) => {
const data = {
id,
url: `${env.SITE_URL}/${id}.${highlight}`,
highlight,
encrypted: !!password,
contents: pasteContents,
@ -148,15 +147,20 @@ export const POST: RequestHandler = async ({ request }) => {
const pastes = await Mongo.getNamedCollection("pastes");
const res = await pastes.insertOne(data);
const url = `${env.SITE_URL}/${id}.${highlight}`;
if (!res.acknowledged) {
throw error(500, 'Failed to create paste');
}
if (raw) {
return json(data, {
return json({
...data,
url,
}, {
status: 201,
});
} else {
return text(data.url + '\n');
return text(url + '\n');
}
};