diff --git a/app/scenes/CollectionEdit.tsx b/app/scenes/CollectionEdit.tsx index a33602e4d..e3c9c4689 100644 --- a/app/scenes/CollectionEdit.tsx +++ b/app/scenes/CollectionEdit.tsx @@ -74,7 +74,7 @@ const CollectionEdit = ({ collectionId, onSubmit }: Props) => { }; const handleNameChange = (ev: React.ChangeEvent) => { - setName(ev.target.value.trim()); + setName(ev.target.value); }; const handleChange = (color: string, icon: string) => { diff --git a/server/routes/api/collections.test.ts b/server/routes/api/collections.test.ts index 6fd3a5da8..44a534225 100644 --- a/server/routes/api/collections.test.ts +++ b/server/routes/api/collections.test.ts @@ -1253,14 +1253,14 @@ describe("#collections.update", () => { expect(body.data.name).toBe(collection.name); }); - it("allows editing from non-private to private collection", async () => { + it("allows editing from non-private to private collection, and trims whitespace", async () => { const { user, collection } = await seed(); const res = await server.post("/api/collections.update", { body: { token: user.getJwtToken(), id: collection.id, permission: null, - name: "Test", + name: " Test ", }, }); const body = await res.json(); diff --git a/server/routes/api/collections.ts b/server/routes/api/collections.ts index 7579b563e..70a476df1 100644 --- a/server/routes/api/collections.ts +++ b/server/routes/api/collections.ts @@ -536,7 +536,7 @@ router.post("collections.update", auth(), async (ctx) => { let sharingChanged = false; if (name !== undefined) { - collection.name = name; + collection.name = name.trim(); } if (description !== undefined) {