Skip to content

Commit 82b5604

Browse files
authored
Merge pull request #1353 from RoboSats/fix-custom-coordinator-error
Fix RegExp and Avatar
2 parents 10c1801 + a27709e commit 82b5604

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

frontend/src/basic/SettingsPage/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ const SettingsPage = (): JSX.Element => {
1414
const [newUrl, setNewUrl] = useState<string>('');
1515
const [error, setError] = useState<string>();
1616
// Regular expression to match a valid .onion URL
17-
const onionUrlPattern = /^(http:\/\/|https:\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
17+
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
1818

1919
const addCoordinator = () => {
2020
if (federation.coordinators[newAlias]) {
2121
setError(t('Alias already exists'));
2222
} else {
2323
if (onionUrlPattern.test(newUrl)) {
24-
addNewCoordinator(newAlias, newUrl);
24+
let fullNewUrl = newUrl;
25+
if (!/^((http|https):\/\/)/.test(fullNewUrl)) {
26+
fullNewUrl = `http://${newUrl}`;
27+
}
28+
addNewCoordinator(newAlias, fullNewUrl);
2529
setNewAlias('');
2630
setNewUrl('');
2731
} else {

frontend/src/components/Dialogs/Coordinator.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ const BadgesHall = ({ badges, size_limit }: BadgesProps): JSX.Element => {
344344
);
345345
};
346346

347-
const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props): JSX.Element => {
347+
const CoordinatorDialog = ({ open = false, onClose, shortAlias }: Props): JSX.Element => {
348348
const { t } = useTranslation();
349349
const { clientVersion, page, settings, origin } = useContext(AppContext);
350350
const { federation } = useContext<UseFederationStoreType>(FederationContext);
@@ -369,7 +369,7 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props
369369
<Grid item>
370370
<RobotAvatar
371371
shortAlias={coordinator?.federated ? coordinator?.shortAlias : undefined}
372-
hashId={coordinator?.federated ? undefined : coordinator?.shortAlias}
372+
hashId={coordinator?.federated ? undefined : coordinator?.mainnet.onion}
373373
style={{ width: '7.5em', height: '7.5em' }}
374374
smooth={true}
375375
/>

0 commit comments

Comments
 (0)