diff --git a/src/server.rs b/src/server.rs index e866016..07e1c77 100644 --- a/src/server.rs +++ b/src/server.rs @@ -163,7 +163,7 @@ async fn handle_ws(mut socket: WebSocket) { _ => unreachable!("got non-text message from websocket"), }; - let (mut level, mut text) = msg.split_once(',').unwrap(); + let (mut level, mut text) = msg.trim_ascii().split_once(',').unwrap(); if let Some(rest) = text.strip_prefix("TRACE ") { level = "debug"; diff --git a/static/index.html b/static/index.html index 1b7e0af..2f6118d 100644 --- a/static/index.html +++ b/static/index.html @@ -34,7 +34,7 @@ // {{ MODULE }} async function run() { - await wasm_bindgen({module_or_path: "/api/wasm.wasm"}).catch(error => { + await wasm_bindgen({module_or_path: "./api/wasm.wasm"}).catch(error => { if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) { throw error; } @@ -44,7 +44,13 @@ const reloadInterval = 1000; async function startReloadInterval() { - const fetchVersion = () => fetch("/api/version").then(response => response.text()); + async function fetchVersion() { + let response = await fetch("./api/version"); + if (!response.ok) { + throw new Error(); + } + return await response.text(); + } const version = await fetchVersion(); let intervalToken; @@ -62,7 +68,7 @@ } let queuedMessages = []; - let websocket = new WebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/ws"); + let websocket = new WebSocket("./ws"); function formatValue(value) { return String(value); // TODO