Skip to content

Commit

Permalink
fix: enable support for firebasedatabase.app
Browse files Browse the repository at this point in the history
  • Loading branch information
thameezb committed Mar 13, 2021
1 parent a957589 commit ee9d30b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func NewClient(ctx context.Context, c *internal.DatabaseConfig) (*Client, error)
return nil, err
} else if p.Scheme != "https" {
return nil, fmt.Errorf("invalid database URL: %q; want scheme: %q", c.URL, "https")
} else if !strings.HasSuffix(p.Host, ".firebaseio.com") {
return nil, fmt.Errorf("invalid database URL: %q; want host: %q", c.URL, "firebaseio.com")
} else if !(strings.HasSuffix(p.Host, ".firebaseio.com") || strings.HasSuffix(p.Host, ".firebasedatabase.app")) {
return nil, fmt.Errorf("invalid database URL: %q; want host: %q or %q", c.URL, "firebaseio.com", ".firebasedatabase.app")
}

var ao []byte
Expand Down
19 changes: 19 additions & 0 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ func TestNewClientAuthOverrides(t *testing.T) {
}
}

func TestValidURLS(t *testing.T) {
cases := []string{
"https://test-db.firebaseio.com",
"https://test-db.firebasedatabase.app",
}
for _, tc := range cases {
c, err := NewClient(context.Background(), &internal.DatabaseConfig{
Opts: testOpts,
URL: tc,
})
if err != nil {
t.Fatal(err)
}
if c.url != tc {
t.Errorf("NewClient(%v).url = %q; want = %q", tc, c.url, testURL)
}
}
}

func TestInvalidURL(t *testing.T) {
cases := []string{
"",
Expand Down

0 comments on commit ee9d30b

Please sign in to comment.