File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -77,10 +77,20 @@ export class Base {
7777export class ReferenceBase extends Base {
7878 constructor ( firestack , path ) {
7979 super ( firestack ) ;
80+
8081 this . path = Array . isArray ( path ) ?
8182 path :
8283 ( typeof path == 'string' ?
8384 [ path ] : [ ] ) ;
85+
86+ // sanitize path, just in case
87+ this . path = this . path
88+ . filter ( str => str !== "" ) ;
89+ }
90+
91+ get key ( ) {
92+ const path = this . path ;
93+ return path . length === 0 ? '/' : path [ path . length - 1 ] ;
8494 }
8595
8696 pathToString ( ) {
Original file line number Diff line number Diff line change @@ -169,7 +169,9 @@ class DatabaseRef extends ReferenceBase {
169169 push ( value = { } ) {
170170 const path = this . dbPath ( ) ;
171171 return promisify ( 'push' , FirestackDatabase ) ( path , value )
172- . then ( ( { ref} ) => new DatabaseRef ( this . db , ref ) )
172+ . then ( ( { ref} ) => {
173+ return new DatabaseRef ( this . db , ref . split ( separator ) )
174+ } )
173175 }
174176
175177 on ( evt , cb ) {
@@ -247,7 +249,7 @@ class DatabaseRef extends ReferenceBase {
247249
248250 // attributes
249251 get fullPath ( ) {
250- return this . dbPath ( ) . path ;
252+ return this . dbPath ( ) ;
251253 }
252254
253255 get name ( ) {
You can’t perform that action at this time.
0 commit comments