From cdcabb240f9afcab504ca26fbf71d3af013dd806 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 18 Aug 2021 19:42:14 +0300 Subject: [PATCH] fix: respect protocol from browser for manual setup (#3675) --- client-src/utils/createSocketURL.js | 2 +- test/client/utils/createSocketURL.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client-src/utils/createSocketURL.js b/client-src/utils/createSocketURL.js index b49ae98b78..168c3b6c9e 100644 --- a/client-src/utils/createSocketURL.js +++ b/client-src/utils/createSocketURL.js @@ -21,7 +21,7 @@ function createSocketURL(parsedURL) { hostname = self.location.hostname; } - let socketURLProtocol = parsedURL.protocol || "ws:"; + let socketURLProtocol = parsedURL.protocol || self.location.protocol; // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets. if ( diff --git a/test/client/utils/createSocketURL.test.js b/test/client/utils/createSocketURL.test.js index 01e2feadb3..393ed96a50 100644 --- a/test/client/utils/createSocketURL.test.js +++ b/test/client/utils/createSocketURL.test.js @@ -55,7 +55,7 @@ describe("'createSocketURL' function ", () => { ["?hostname=%3A%3A", "http://example.com:8080", "ws://example.com:8080/ws"], ["?hostname=%3A%3A1", "http://example.com:8080", "ws://[::1]:8080/ws"], - ["?hostname=%3A%3A1", "https://example.com:8080", "ws://[::1]:8080/ws"], + ["?hostname=%3A%3A1", "https://example.com:8080", "wss://[::1]:8080/ws"], [ "?hostname=%3A%3A", "https://example.com:8080",