Prevents adding ws relay when over https

This commit is contained in:
Ivan Acosta-Rubio 2023-03-26 05:54:35 -06:00
parent e95f1fe369
commit 2580fd33e5
No known key found for this signature in database
GPG Key ID: F67EC2811EE4211D
1 changed files with 9 additions and 1 deletions

View File

@ -31,6 +31,14 @@ const RelaySettingsPage = () => {
}
}
const handleNewRelayChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const inputValue = event.target.value;
const protocol = window.location.protocol;
if ((protocol === "https:" && inputValue.startsWith("wss://")) || protocol === "http:") {
setNewRelay(inputValue);
}
};
function addRelay() {
return (
<>
@ -43,7 +51,7 @@ const RelaySettingsPage = () => {
className="f-grow"
placeholder="wss://my-relay.com"
value={newRelay}
onChange={e => setNewRelay(e.target.value)}
onChange={handleNewRelayChange}
/>
</div>
<button className="secondary mb10" onClick={() => addNewRelay()}>