From e2fd934851b6fed28369103082e7aeecc478e3e7 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Tue, 4 May 2021 17:54:21 +0200 Subject: [PATCH] Allow base URL with path Ignore and remove trailing slashes. Fixes #134. Change-Id: Iedf266e9a93e6939f7f66707fee59a2b56226216 --- src/components/LoginPage.js | 4 +++- src/synapse/authProvider.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/LoginPage.js b/src/components/LoginPage.js index 4c222a3..e432904 100644 --- a/src/components/LoginPage.js +++ b/src/components/LoginPage.js @@ -111,7 +111,9 @@ const LoginPage = ({ theme }) => { if (!values.base_url.match(/^(http|https):\/\//)) { errors.base_url = translate("synapseadmin.auth.protocol_error"); } else if ( - !values.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?$/) + !values.base_url.match( + /^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?[^?&\s]*$/ + ) ) { errors.base_url = translate("synapseadmin.auth.url_error"); } diff --git a/src/synapse/authProvider.js b/src/synapse/authProvider.js index f36b9d1..11433a3 100644 --- a/src/synapse/authProvider.js +++ b/src/synapse/authProvider.js @@ -18,6 +18,7 @@ const authProvider = { // use the base_url from login instead of the well_known entry from the // server, since the admin might want to access the admin API via some // private address + base_url = base_url.replace(/\/+$/g, ""); localStorage.setItem("base_url", base_url); const decoded_base_url = window.decodeURIComponent(base_url);