From e5e8d33df72182cf7dd15e1c1fb9127bc789dd85 Mon Sep 17 00:00:00 2001 From: Jay Meistrich Date: Sun, 16 Jun 2024 18:08:52 -0700 Subject: [PATCH] fix: remove accidental double / from firebase paths --- src/sync-plugins/firebase.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sync-plugins/firebase.ts b/src/sync-plugins/firebase.ts index 4a51e287..7f819e8a 100644 --- a/src/sync-plugins/firebase.ts +++ b/src/sync-plugins/firebase.ts @@ -74,6 +74,10 @@ export function configureSyncedFirebase(config: SyncedFirebaseConfiguration) { } } +function joinPaths(str1: string, str2: string) { + return str2 ? [str1, str2].join('/').replace(/\/\//g, '/') : str1; +} + interface FirebaseFns { isInitialized: () => boolean; getCurrentUser: () => string | undefined; @@ -288,7 +292,7 @@ export function syncedFirebase { - const path = - refPath(fns.getCurrentUser()) + (fieldId && asType !== 'value' ? '/' + (input as any)[fieldId] : ''); + const path = joinPaths( + refPath(fns.getCurrentUser()), + fieldId && asType !== 'value' ? (input as any)[fieldId] : '', + ); return fns.remove(fns.ref(path)); };