Skip to content

Build your personal knowledge base with Trilium Notes

make :filename for GETing an image optional

Tomf53a93e828c6
diff --git a/src/routes/routes.js b/src/routes/routes.js
index f899e4f7d2..0cd2460c98 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -285,7 +285,7 @@ function register(app) {
apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
- route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
+ route(GET, ['/api/images/:noteId/:filename', '/api/images/:noteId'], [auth.checkApiAuthOrElectron], imageRoute.returnImage);
route(POST, '/api/images', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.uploadImage, apiResultHandler);
route(PUT, '/api/images/:noteId', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.updateImage, apiResultHandler);
diff --git a/src/share/routes.js b/src/share/routes.js
index 4aa90163a7..1a6e42be2b 100644
--- a/src/share/routes.js
+++ b/src/share/routes.js
@@ -108,7 +108,7 @@ function register(router) {
res.send(note.getContent());
});
- router.get('/share/api/images/:noteId/:filename', (req, res, next) => {
+ router.get(['/share/api/images/:noteId/:filename', '/share/api/images/:noteId'], (req, res, next) => {
const image = shaca.getNote(req.params.noteId);
if (!image) {