Skip to content

Build your personal knowledge base with Trilium Notes

set note type/mime in PUT body to avoid http proxy slash reencoding, fixes #2419

zadam97f7fe7b18a7
diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js
index 7744838d3d..a81e446e3f 100644
--- a/src/public/app/widgets/note_type.js
+++ b/src/public/app/widgets/note_type.js
@@ -133,9 +133,7 @@ export default class NoteTypeWidget extends NoteContextAwareWidget {
return;
}
- await server.put('notes/' + this.noteId
- + '/type/' + encodeURIComponent(type)
- + '/mime/' + encodeURIComponent(mime));
+ await server.put('notes/' + this.noteId + '/type', { type, mime });
}
async confirmChangeIfContent() {
diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js
index d1d0c333cc..883c396004 100644
--- a/src/routes/api/notes.js
+++ b/src/routes/api/notes.js
@@ -120,9 +120,8 @@ function protectNote(req) {
function setNoteTypeMime(req) {
// can't use [] destructuring because req.params is not iterable
- const noteId = req.params[0];
- const type = req.params[1];
- const mime = req.params[2];
+ const {noteId} = req.params;
+ const {type, mime} = req.body;
const note = becca.getNote(noteId);
note.type = type;
diff --git a/src/routes/routes.js b/src/routes/routes.js
index 9cc3f5a837..d0f69e39cd 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -213,7 +213,7 @@ function register(app) {
apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote);
apiRoute(PUT, '/api/notes/:noteId/sort-children', notesApiRoute.sortChildNotes);
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote);
- apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime);
+ apiRoute(PUT, '/api/notes/:noteId/type', notesApiRoute.setNoteTypeMime);
apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions);
apiRoute(DELETE, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.eraseAllNoteRevisions);
apiRoute(GET, '/api/notes/:noteId/revisions/:noteRevisionId', noteRevisionsApiRoute.getNoteRevision);