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 11- 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', () => {
529529 expect ( path ) . to . equal ( '/bar' ) ;
530530 } ) ;
531531
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+
532548 it ( 'should return the correct multi-region instance and path strings if domain is present' , ( ) => {
533549 const [ instance , path ] = database . extractInstanceAndPath (
534550 'projects/_/instances/foo/refs/bar' ,
Original file line number Diff line number Diff line change @@ -307,6 +307,8 @@ export class RefBuilder {
307307 } ;
308308}
309309
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+
310312/**
311313 * Utility function to extract database reference from resource string
312314 *
@@ -320,7 +322,6 @@ export function extractInstanceAndPath(
320322 resource : string ,
321323 domain = 'firebaseio.com'
322324) {
323- const resourceRegex = `projects/([^/]+)/instances/([a-zA-Z0-9\-^/]+)/refs(/.+)?` ;
324325 const match = resource . match ( new RegExp ( resourceRegex ) ) ;
325326 if ( ! match ) {
326327 throw new Error (
You can’t perform that action at this time.
0 commit comments