Skip to content

Commit

Permalink
fix: handle deletions when the parent is not an object or null
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Apr 12, 2024
1 parent 76484a2 commit 6839ffb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-tomatoes-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@andipaetzold/realtime-server": patch
---

Handle deletions when the parent is not an object or null
4 changes: 4 additions & 0 deletions packages/realtime-server/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export function createStore(initialData: any): Store {
const lastPath = path.slice(lastSlashIndex + 1);

const parent = getWithPath(data, parentPath);
if (typeof parent !== "object" || parent === null) {
return
}

if (Array.isArray(parent)) {
if (isNaN(Number(lastPath))) {
return;
Expand Down

0 comments on commit 6839ffb

Please sign in to comment.