Prevents adding ws relay when over https #463

Merged
ivanacostarubio merged 1 commits from issue/451 into main 2023-03-29 14:43:38 +00:00

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()}>