Skip to content

Commit 8124282

Browse files
authored
Add header for opting into correct URL decoding (#186)
* Add header for opting into correct URL decoding There is a long standing bug (~years) in the RTDB url decoding where we URL decode query parameters twice. Since we can't simply fix the issue without breaking users, we allow an opt-in upgrade/fix of the correct behavior via a header `X-Firebase-Decoding: 1`. We hope to make this the default (correct) behavior at some point in the near future. Which then this header will not be needed anymore. * Add test assertions for X-Firebase-Decoding
1 parent 361aa51 commit 8124282

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

db/db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (c *Client) send(
116116
if c.authOverride != "" {
117117
opts = append(opts, internal.WithQueryParam(authVarOverride, c.authOverride))
118118
}
119+
opts = append(opts, internal.WithHeader("X-Firebase-Decoding", "1"))
119120
return c.hc.Do(ctx, &internal.Request{
120121
Method: method,
121122
URL: fmt.Sprintf("%s%s.json", c.url, path),

db/db_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ func checkRequest(t *testing.T, got, want *testReq) {
274274
if h := got.Header.Get("Authorization"); h != "Bearer mock-token" {
275275
t.Errorf("Authorization = %q; want = %q", h, "Bearer mock-token")
276276
}
277+
if h := got.Header.Get("X-Firebase-Decoding"); h != "1" {
278+
t.Errorf("X-Firebase-Decoding = %q; want = %q", h, "1")
279+
}
277280
if h := got.Header.Get("User-Agent"); h != testUserAgent {
278281
t.Errorf("User-Agent = %q; want = %q", h, testUserAgent)
279282
}

0 commit comments

Comments
 (0)