Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ 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")
}

var ao []byte
Expand Down
21 changes: 20 additions & 1 deletion db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,31 @@ 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{
"",
"foo",
"http://db.firebaseio.com",
"https://firebase.google.com",
"http://firebase.google.com",
}
for _, tc := range cases {
c, err := NewClient(context.Background(), &internal.DatabaseConfig{
Expand Down