diff --git a/frontend/src/basic/SettingsPage/index.tsx b/frontend/src/basic/SettingsPage/index.tsx index 26d4fa3c..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