Skip to content

Commit ee9d30b

Browse files
committed
fix: enable support for firebasedatabase.app
1 parent a957589 commit ee9d30b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

db/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func NewClient(ctx context.Context, c *internal.DatabaseConfig) (*Client, error)
4848
return nil, err
4949
} else if p.Scheme != "https" {
5050
return nil, fmt.Errorf("invalid database URL: %q; want scheme: %q", c.URL, "https")
51-
} else if !strings.HasSuffix(p.Host, ".firebaseio.com") {
52-
return nil, fmt.Errorf("invalid database URL: %q; want host: %q", c.URL, "firebaseio.com")
51+
} else if !(strings.HasSuffix(p.Host, ".firebaseio.com") || strings.HasSuffix(p.Host, ".firebasedatabase.app")) {
52+
return nil, fmt.Errorf("invalid database URL: %q; want host: %q or %q", c.URL, "firebaseio.com", ".firebasedatabase.app")
5353
}
5454

5555
var ao []byte

db/db_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ func TestNewClientAuthOverrides(t *testing.T) {
136136
}
137137
}
138138

139+
func TestValidURLS(t *testing.T) {
140+
cases := []string{
141+
"https://test-db.firebaseio.com",
142+
"https://test-db.firebasedatabase.app",
143+
}
144+
for _, tc := range cases {
145+
c, err := NewClient(context.Background(), &internal.DatabaseConfig{
146+
Opts: testOpts,
147+
URL: tc,
148+
})
149+
if err != nil {
150+
t.Fatal(err)
151+
}
152+
if c.url != tc {
153+
t.Errorf("NewClient(%v).url = %q; want = %q", tc, c.url, testURL)
154+
}
155+
}
156+
}
157+
139158
func TestInvalidURL(t *testing.T) {
140159
cases := []string{
141160
"",

0 commit comments

Comments
 (0)