Merge pull request #1353 from RoboSats/fix-custom-coordinator-error

Fix RegExp and Avatar
This commit is contained in:
KoalaSat 2024-06-26 14:27:04 +00:00 committed by GitHub
commit 82b5604ecb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -14,14 +14,18 @@ const SettingsPage = (): JSX.Element => {
const [newUrl, setNewUrl] = useState<string>('');
const [error, setError] = useState<string>();
// 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 {

View File

@ -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<UseFederationStoreType>(FederationContext);
@ -369,7 +369,7 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props
<Grid item>
<RobotAvatar
shortAlias={coordinator?.federated ? coordinator?.shortAlias : undefined}
hashId={coordinator?.federated ? undefined : coordinator?.shortAlias}
hashId={coordinator?.federated ? undefined : coordinator?.mainnet.onion}
style={{ width: '7.5em', height: '7.5em' }}
smooth={true}
/>