I am in a web page environment. I want to open a websocket. If the webpage I am ...
mcc @mcc@mastodon.social
I am in a web page environment. I want to open a websocket. If the webpage I am embedded in was served using https, I want to access via a wss:// url. otherwise, I want to access via a ws:// url.
1. Is there a less absurd way to do this than to check `new URL(window.location.href).protocol`?
2. Does this answer change if I am running in Rust wasm instead of JavaScript?