mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 19:06:26 +00:00
Merge pull request #1353 from RoboSats/fix-custom-coordinator-error
Fix RegExp and Avatar
This commit is contained in:
commit
82b5604ecb
@ -14,14 +14,18 @@ const SettingsPage = (): JSX.Element => {
|
|||||||
const [newUrl, setNewUrl] = useState<string>('');
|
const [newUrl, setNewUrl] = useState<string>('');
|
||||||
const [error, setError] = useState<string>();
|
const [error, setError] = useState<string>();
|
||||||
// Regular expression to match a valid .onion URL
|
// 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 = () => {
|
const addCoordinator = () => {
|
||||||
if (federation.coordinators[newAlias]) {
|
if (federation.coordinators[newAlias]) {
|
||||||
setError(t('Alias already exists'));
|
setError(t('Alias already exists'));
|
||||||
} else {
|
} else {
|
||||||
if (onionUrlPattern.test(newUrl)) {
|
if (onionUrlPattern.test(newUrl)) {
|
||||||
addNewCoordinator(newAlias, newUrl);
|
let fullNewUrl = newUrl;
|
||||||
|
if (!/^((http|https):\/\/)/.test(fullNewUrl)) {
|
||||||
|
fullNewUrl = `http://${newUrl}`;
|
||||||
|
}
|
||||||
|
addNewCoordinator(newAlias, fullNewUrl);
|
||||||
setNewAlias('');
|
setNewAlias('');
|
||||||
setNewUrl('');
|
setNewUrl('');
|
||||||
} else {
|
} else {
|
||||||
|
@ -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 { t } = useTranslation();
|
||||||
const { clientVersion, page, settings, origin } = useContext(AppContext);
|
const { clientVersion, page, settings, origin } = useContext(AppContext);
|
||||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
||||||
@ -369,7 +369,7 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props
|
|||||||
<Grid item>
|
<Grid item>
|
||||||
<RobotAvatar
|
<RobotAvatar
|
||||||
shortAlias={coordinator?.federated ? coordinator?.shortAlias : undefined}
|
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' }}
|
style={{ width: '7.5em', height: '7.5em' }}
|
||||||
smooth={true}
|
smooth={true}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user