Fix screenshot assets and code blocks
This commit is contained in:
+7
-2
@@ -20,6 +20,7 @@ import {
|
||||
const app = express();
|
||||
|
||||
app.disable("x-powered-by");
|
||||
app.enable("strict routing");
|
||||
app.use(express.json({ limit: "1mb" }));
|
||||
|
||||
function requireAdmin(req: Request, res: Response, next: NextFunction): void {
|
||||
@@ -49,7 +50,7 @@ function publicCapture(row: ReturnType<typeof store.getCapture>) {
|
||||
createdAt: row.created_at,
|
||||
updatedAt: row.updated_at,
|
||||
capturedAt: row.captured_at,
|
||||
publicUrl: row.slug ? `${config.baseUrl}/${row.slug}` : null
|
||||
publicUrl: row.slug ? `${config.baseUrl}/${row.slug}/` : null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ app.get(`${config.basePath}/:slug/download.zip`, async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get(`${config.basePath}/:slug`, async (req, res) => {
|
||||
app.get(`${config.basePath}/:slug/`, async (req, res) => {
|
||||
const row = store.getCaptureBySlug(req.params.slug);
|
||||
if (!row) {
|
||||
res.status(404).send("Not found");
|
||||
@@ -193,6 +194,10 @@ app.get(`${config.basePath}/:slug`, async (req, res) => {
|
||||
.send(`<!doctype html><meta name="robots" content="noindex"><title>${row.title || "AI Share"}</title><p>${row.error_public || `Capture is ${row.status}.`}</p>`);
|
||||
});
|
||||
|
||||
app.get(`${config.basePath}/:slug`, (req, res) => {
|
||||
res.redirect(308, `${config.basePath}/${req.params.slug}/`);
|
||||
});
|
||||
|
||||
app.get(config.basePath, (_req, res) => {
|
||||
res.redirect(301, `${config.basePath}/admin`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user