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

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() { function addRelay() {
return ( return (
<> <>
@ -43,7 +51,7 @@ const RelaySettingsPage = () => {
className="f-grow" className="f-grow"
placeholder="wss://my-relay.com" placeholder="wss://my-relay.com"
value={newRelay} value={newRelay}
onChange={e => setNewRelay(e.target.value)} onChange={handleNewRelayChange}
/> />
</div> </div>
<button className="secondary mb10" onClick={() => addNewRelay()}> <button className="secondary mb10" onClick={() => addNewRelay()}>