Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
12 changes: 9 additions & 3 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;

Expand All @@ -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
Expand Down