Skip to content

Commit 18d371c

Browse files
thameezbhiranya911
andauthored
fix(rtdb): enable support for firebasedatabase.app (#423)
* fix: enable support for firebasedatabase.app * fix: remove static URL check Co-authored-by: Hiranya Jayathilaka <hiranya911@gmail.com>
1 parent 88d217a commit 18d371c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

db/db.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ 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")
5351
}
5452

5553
var ao []byte

db/db_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,31 @@ 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
"",
142161
"foo",
143162
"http://db.firebaseio.com",
144-
"https://firebase.google.com",
163+
"http://firebase.google.com",
145164
}
146165
for _, tc := range cases {
147166
c, err := NewClient(context.Background(), &internal.DatabaseConfig{

0 commit comments

Comments
 (0)