File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
- Add support for more regions and memory for v2 functions (#1037 ).
2
+ - Fixes bug where some RTDB instance names were incorrectly parsed (#1056 ).
Original file line number Diff line number Diff line change @@ -529,6 +529,22 @@ describe('Database Functions', () => {
529
529
expect ( path ) . to . equal ( '/bar' ) ;
530
530
} ) ;
531
531
532
+ it ( 'should return the correct instance and path strings if root path is /refs' , ( ) => {
533
+ const [ instance , path ] = database . extractInstanceAndPath (
534
+ 'projects/_/instances/foo/refs/refs'
535
+ ) ;
536
+ expect ( instance ) . to . equal ( 'https://foo.firebaseio.com' ) ;
537
+ expect ( path ) . to . equal ( '/refs' ) ;
538
+ } ) ;
539
+
540
+ it ( 'should return the correct instance and path strings if a child path contain /refs' , ( ) => {
541
+ const [ instance , path ] = database . extractInstanceAndPath (
542
+ 'projects/_/instances/foo/refs/root/refs'
543
+ ) ;
544
+ expect ( instance ) . to . equal ( 'https://foo.firebaseio.com' ) ;
545
+ expect ( path ) . to . equal ( '/root/refs' ) ;
546
+ } ) ;
547
+
532
548
it ( 'should return the correct multi-region instance and path strings if domain is present' , ( ) => {
533
549
const [ instance , path ] = database . extractInstanceAndPath (
534
550
'projects/_/instances/foo/refs/bar' ,
Original file line number Diff line number Diff line change @@ -307,6 +307,8 @@ export class RefBuilder {
307
307
} ;
308
308
}
309
309
310
+ const resourceRegex = / ^ p r o j e c t s \/ ( [ ^ / ] + ) \/ i n s t a n c e s \/ ( [ a - z A - Z 0 - 9 - ] + ) \/ r e f s ( \/ .+ ) ? / ;
311
+
310
312
/**
311
313
* Utility function to extract database reference from resource string
312
314
*
@@ -320,7 +322,6 @@ export function extractInstanceAndPath(
320
322
resource : string ,
321
323
domain = 'firebaseio.com'
322
324
) {
323
- const resourceRegex = `projects/([^/]+)/instances/([a-zA-Z0-9\-^/]+)/refs(/.+)?` ;
324
325
const match = resource . match ( new RegExp ( resourceRegex ) ) ;
325
326
if ( ! match ) {
326
327
throw new Error (
You can’t perform that action at this time.
0 commit comments