From: Adam Dullage Date: Thu, 4 Jul 2024 17:32:07 +0000 (+0100) Subject: Update API calls to encode note titles in API URLs X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=510a5f4e6576245d4e41f7267d8b6561d68d7a67;p=flatnotes.git Update API calls to encode note titles in API URLs --- diff --git a/client/api.js b/client/api.js index 46e3dca..d27d3b5 100644 --- a/client/api.js +++ b/client/api.js @@ -95,7 +95,7 @@ export async function createNote(title, content) { export async function getNote(title) { try { - const response = await api.get(`api/notes/${title}`); + const response = await api.get(`api/notes/${encodeURIComponent(title)}`); return new Note(response.data); } catch (response) { return Promise.reject(response); @@ -104,7 +104,7 @@ export async function getNote(title) { export async function updateNote(title, newTitle, newContent) { try { - const response = await api.patch(`api/notes/${title}`, { + const response = await api.patch(`api/notes/${encodeURIComponent(title)}`, { newTitle: newTitle, newContent: newContent, }); @@ -116,7 +116,7 @@ export async function updateNote(title, newTitle, newContent) { export async function deleteNote(title) { try { - await api.delete(`api/notes/${title}`); + await api.delete(`api/notes/${encodeURIComponent(title)}`); } catch (response) { return Promise.reject(response); }