From 4b995d970bc37c13d8653cce9277d41532c34290 Mon Sep 17 00:00:00 2001 From: Anton Makarov Date: Wed, 19 Nov 2025 21:30:49 +0300 Subject: [PATCH] Changes --- go.mod | 2 +- js/src/main.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 40aa386..2581bd8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/sorenisanerd/gotty +module gitea.xs0.ru/forks/gotty go 1.23 diff --git a/js/src/main.ts b/js/src/main.ts index ae86c14..fa2a03f 100644 --- a/js/src/main.ts +++ b/js/src/main.ts @@ -9,13 +9,16 @@ declare var gotty_ws_query_args: string; const elem = document.getElementById("terminal") +function stripns(pd) { if (pd.substring(pd.length-1) == '/') { return pd; } else { return stripns(pd.substring(0,pd.length-1)); } } + if (elem !== null) { var term: Terminal; term = new GoTTYXterm(elem); const httpsEnabled = window.location.protocol == "https:"; const queryArgs = (gotty_ws_query_args === "") ? "" : "?" + gotty_ws_query_args; - const url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws' + queryArgs; + const pathdir = stripns(window.location.pathname); + const url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + pathdir + 'ws' + queryArgs; const args = window.location.search; const factory = new ConnectionFactory(url, protocols); const wt = new WebTTY(term, factory, args, gotty_auth_token); @@ -28,4 +31,8 @@ if (elem !== null) { closer(); term.close(); }); + + window.addEventListener("beforeunload", (e) => { + return 'No no no Ctrl-W is pressed. Or did you REALLY mean to close this tab?'; + }); };