From fd3a34fc20a79060231b304a1ddc3b0afbcb50f4 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 21 Nov 2025 18:57:23 +0900 Subject: [PATCH] Update websocket.js for improved path handling Refactored default WebSocket executable path selection to check for a user-specific installation before falling back to architecture-based defaults. Updated comments for clarity and incremented version to 0.2.4. --- lib/websocket.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/websocket.js b/lib/websocket.js index 62ac48c..5e113ef 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -1,11 +1,15 @@ // websocket.js -// Copyright 2019-2025, Namhyeon Go and the WelsonJS contributors. +// Namhyeon Go and the WelsonJS contributors. // SPDX-License-Identifier: GPL-3.0-or-later // https://github.com/gnh1201/welsonjs // -// references: -// https://stackoverflow.com/questions/52783655/use-curl-with-chrome-remote-debugging -// https://github.com/vi/websocat +// Please Note: +// If you want more fine-grained control over WebSockets, please refer to the WebSocket implementation in the WelsonJS Launcher. +// This file exists for compatibility with previous versions. +// +// References: +// * https://stackoverflow.com/questions/52783655/use-curl-with-chrome-remote-debugging +// * https://github.com/vi/websocat // var SHELL = require("lib/shell"); var SYS = require("lib/system"); @@ -20,11 +24,16 @@ var WebsocketObject = function() { if (typeof(path) !== "undefined") { this._interface.setPrefix(path); } else { - var arch = SYS.getArch(); - if(arch.indexOf("64") > -1) { - this._interface.setPrefix("bin\\x64\\websocat.x86_64-pc-windows-gnu.exe"); + var default_websocat_path = SYS.getAppDataDir() + "\\websocat\\websocat.exe"; + if (FILE.fileExists(default_websocat_path)) { + this._interface.setPrefix(default_websocat_path); } else { - this._interface.setPrefix("bin\\x86\\websocat.i686-pc-windows-gnu.exe"); + var arch = SYS.getArch(); + if(arch.indexOf("64") > -1) { + this._interface.setPrefix("bin\\x64\\websocat.x86_64-pc-windows-gnu.exe"); + } else { + this._interface.setPrefix("bin\\x86\\websocat.i686-pc-windows-gnu.exe"); + } } } }; @@ -67,7 +76,7 @@ var WebsocketObject = function() { this.create(); }; -exports.VERSIONINFO = "Websocket Interface (websocket.js) version 0.2.3"; +exports.VERSIONINFO = "Websocket interface (websocket.js) version 0.2.4"; exports.global = global; exports.require = global.require;