From 8416372c8f27e296acac8c981a50737a9b81f27e Mon Sep 17 00:00:00 2001 From: Lukas Kurucz Date: Fri, 4 Mar 2022 03:46:06 -0800 Subject: [PATCH] fix: encode ws url (#3498) Summary: Some clients require encoded ws url. For example on Android (running in Rect Native), plain URL like this: `ws://10.0.2.2:8333?device_id=ReactNative1646120067758.0.2246373385349361&device=ReactNative&app=React Native App Google - Android SDK&os=ReactNative` will throw error during connection. To not require param encoding when starting the `flipperClient.start()`, it is easier to encode entire `url` before starting the ws server. ## Changelog - encode url for `js-flipper` ws server Pull Request resolved: https://github.com/facebook/flipper/pull/3498 Reviewed By: aigoncharov Differential Revision: D34638857 Pulled By: lblasa fbshipit-source-id: 9eb0e268c7bacb5febc19bbb45fe6814fb7a60de --- js/js-flipper/src/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/js-flipper/src/client.ts b/js/js-flipper/src/client.ts index 73d2d50e7..9fc305802 100644 --- a/js/js-flipper/src/client.ts +++ b/js/js-flipper/src/client.ts @@ -214,8 +214,9 @@ export class FlipperClient { private connectToFlipper() { const url = `ws://${this.urlBase}?device_id=${this.device}${this.devicePseudoId}&device=${this.device}&app=${this.appName}&os=${this.os}`; + const encodedUrl = encodeURI(url); - this.ws = this.websocketFactory(url); + this.ws = this.websocketFactory(encodedUrl); this.ws.onerror = (error) => { this.onError(error);