From 17a077b5a08ff920019bfb26314286fd63b5895f Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Tue, 25 Jun 2024 18:21:07 +0200 Subject: [PATCH 1/2] Fix RegExp --- frontend/src/basic/SettingsPage/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/basic/SettingsPage/index.tsx b/frontend/src/basic/SettingsPage/index.tsx index 26d4fa3c..f1a004e8 100644 --- a/frontend/src/basic/SettingsPage/index.tsx +++ b/frontend/src/basic/SettingsPage/index.tsx @@ -14,7 +14,7 @@ const SettingsPage = (): JSX.Element => { const [newUrl, setNewUrl] = useState(''); const [error, setError] = useState(); // Regular expression to match a valid .onion URL - const onionUrlPattern = /^(http:\/\/|https:\/\/)?[a-zA-Z2-7]{16,56}\.onion$/; + const onionUrlPattern = /^(http:\/\/|https:\/\/)[a-zA-Z2-7]{16,56}\.onion$/; const addCoordinator = () => { if (federation.coordinators[newAlias]) { From a27709e6578c666f44ae886e7019ccaa9cdf6fdd Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Tue, 25 Jun 2024 20:44:52 +0200 Subject: [PATCH 2/2] Fix Avatar --- frontend/src/basic/SettingsPage/index.tsx | 8 ++++++-- frontend/src/components/Dialogs/Coordinator.tsx | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/basic/SettingsPage/index.tsx b/frontend/src/basic/SettingsPage/index.tsx index f1a004e8..e54d1c07 100644 --- a/frontend/src/basic/SettingsPage/index.tsx +++ b/frontend/src/basic/SettingsPage/index.tsx @@ -14,14 +14,18 @@ const SettingsPage = (): JSX.Element => { const [newUrl, setNewUrl] = useState(''); const [error, setError] = useState(); // Regular expression to match a valid .onion URL - const onionUrlPattern = /^(http:\/\/|https:\/\/)[a-zA-Z2-7]{16,56}\.onion$/; + const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/; const addCoordinator = () => { if (federation.coordinators[newAlias]) { setError(t('Alias already exists')); } else { if (onionUrlPattern.test(newUrl)) { - addNewCoordinator(newAlias, newUrl); + let fullNewUrl = newUrl; + if (!/^((http|https):\/\/)/.test(fullNewUrl)) { + fullNewUrl = `http://${newUrl}`; + } + addNewCoordinator(newAlias, fullNewUrl); setNewAlias(''); setNewUrl(''); } else { diff --git a/frontend/src/components/Dialogs/Coordinator.tsx b/frontend/src/components/Dialogs/Coordinator.tsx index f77bfc45..e60f0b00 100644 --- a/frontend/src/components/Dialogs/Coordinator.tsx +++ b/frontend/src/components/Dialogs/Coordinator.tsx @@ -344,7 +344,7 @@ const BadgesHall = ({ badges, size_limit }: BadgesProps): JSX.Element => { ); }; -const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props): JSX.Element => { +const CoordinatorDialog = ({ open = false, onClose, shortAlias }: Props): JSX.Element => { const { t } = useTranslation(); const { clientVersion, page, settings, origin } = useContext(AppContext); const { federation } = useContext(FederationContext); @@ -369,7 +369,7 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props