Skip to content

Commit a57a38f

Browse files
committed
ws to wss when using https
1 parent dddb159 commit a57a38f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/note_mark/static/script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ function get_ws_event_type(category_id) {
163163
* @param {string} url - the url to connect to
164164
*/
165165
function listen_for_ws_updates(url) {
166+
if (window.location.protocol == "https:") {
167+
url = url.replace("ws:", "wss:")
168+
}
166169
const ws = new WebSocket(url);
167170
ws.onmessage = evnt => {
168171
// parse the message
@@ -234,4 +237,4 @@ window.addEventListener("load", _evnt => {
234237
elements.forEach(elem => {
235238
setTimeout(() => { elem.remove() }, FLASH_EXPIRE_TIME_MS);
236239
});
237-
}, { once: true});
240+
}, { once: true });

0 commit comments

Comments
 (0)