Skip to content

Fix websocketonly flag #6126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 8, 2022
5 changes: 5 additions & 0 deletions .changeset/twenty-shoes-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/database": patch
---

Fix websocketonly field to be set to true when using websocket db url.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what the websocket url is in parens (ws or wss instead of https)? Then someone can figure out how to use it by reading the release notes.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Before you start working on a larger contribution, you should get in touch with

* Create your patch, **including appropriate test cases**. Patches with tests are more likely to be merged.
* Avoid checking in files that shouldn't be tracked (e.g `node_modules`, `gulp-cache`, `.tmp`, `.idea`). If your development setup automatically creates some of these files, please add them to the `.gitignore` at the root of the package (click [here][gitignore] to read more on how to add entries to the `.gitignore`).
* Commit your changes using a commit message that follows our [commit message guidelines](#commit-message-guidelines).
* Commit your changes

```shell
git commit -a
Expand Down
2 changes: 1 addition & 1 deletion packages/database/src/core/util/libs/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const parseRepoInfo = function (
parsedUrl.host,
parsedUrl.secure,
namespace,
nodeAdmin,
webSocketOnly,
nodeAdmin,
/*persistenceKey=*/ '',
/*includeNamespaceInQueryParams=*/ namespace !== parsedUrl.subdomain
),
Expand Down
31 changes: 31 additions & 0 deletions packages/database/test/parser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2017 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022

*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { expect } from "chai";

import { parseRepoInfo } from "../src/core/util/libs/parser";

describe('parser', () => {
it('should set websocketUrl correctly based on the protocol', () => {
const httpsRepoInfo = parseRepoInfo('https://test-ns.firebaseio.com', false);
expect(httpsRepoInfo.repoInfo.webSocketOnly).to.equal(false);
const wssRepoInfo = parseRepoInfo('wss://test-ns.firebaseio.com', false);
expect(wssRepoInfo.repoInfo.webSocketOnly).to.equal(true);
const wsRepoInfo = parseRepoInfo('ws://test-ns.firebaseio.com', false);
expect(wsRepoInfo.repoInfo.webSocketOnly).to.equal(true);
});
});