Merge pull request #463 from ivanacostarubio/issue/451

Prevents adding ws relay when over https
This commit is contained in:
Kieran 2023-03-29 15:43:37 +01:00 committed by GitHub
commit 7d510884c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,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 (
<>
@ -47,7 +55,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()}>