A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: do not throw if note contains invalid tag on sync
thecodrr9546d43c1fa3
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.jsindex 15c83acad..c19e1f918 100644--- a/packages/core/__tests__/notes.test.js+++ b/packages/core/__tests__/notes.test.js@@ -349,3 +349,18 @@ test("repairing notebook references should delete non-existent notebooks", () =>let note = db.notes.note(id);expect(note.notebooks.length).toBe(0);}));++test("adding a remote note with an invalid tag should clean the tag array", () =>+ databaseTest().then(async (db) => {+ await expect(+ db.notes.add({+ ...TEST_NOTE,+ id: "helloworld",+ remote: true,+ tags: ["/.,"],+ })+ ).resolves.toBeUndefined();++ const note = db.notes.note("helloworld");+ expect(note.tags.length).toBe(0);+ }));diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex 3e89d8edf..1cbb476ea 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -39,7 +39,11 @@ export default class Notes extends Collection {if (tags && tags.length) {for (let i = 0; i < tags.length; ++i) {const tag = tags[i];- const addedTag = await this._db.tags.add(tag, id);+ const addedTag = await this._db.tags.add(tag, id).catch(() => void 0);+ if (!addedTag) {+ tags.splice(i, 1);+ continue;+ }if (addedTag.title !== tag) tags[i] = addedTag.title;}}