From 46b6495e71c1ccf06bbca06e1b65cec9400f3a93 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 16 Dec 2020 10:58:16 +0100 Subject: [PATCH] fix #175 --- src/preview/HomeServer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/preview/HomeServer.js b/src/preview/HomeServer.js index d0c19dd..3cb91fc 100644 --- a/src/preview/HomeServer.js +++ b/src/preview/HomeServer.js @@ -14,7 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +function noTrailingSlash(url) { + return url.endsWith("/") ? url.substr(0, url.length - 1) : url; +} + export async function resolveServer(request, baseURL) { + baseURL = noTrailingSlash(baseURL); if (!baseURL.startsWith("http://") && !baseURL.startsWith("https://")) { baseURL = `https://${baseURL}`; } @@ -23,7 +28,7 @@ export async function resolveServer(request, baseURL) { if (status === 200) { const proposedBaseURL = body?.['m.homeserver']?.base_url; if (typeof proposedBaseURL === "string") { - baseURL = proposedBaseURL; + baseURL = noTrailingSlash(proposedBaseURL); } } }