From 32087c357f74c045371216397b32846d13ce807b Mon Sep 17 00:00:00 2001 From: yuhao <76569582+yuhao423@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:38:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8F=A1=E6=89=8B=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: test * sv * fewngo * 3223 * chore: 加入commit提交规范 * chore: 优化commit规范 * workflow: 增加ci检测及加入pr模板 * fix: 修复pnpm format引起的ci问题 * fix: 修复pnpm lint引起的ci问题 * fix: 修复pnpm lint引起的ci问题 * feat: 初始化websocket客户端 * fix: 修改eslint规则,优化websocket(#6) * ci: 去除typescript的ci * refactor: 重构项目,去除typescript * feat: 加入ws 开发依赖等(#13) * fix: 修复无法握手,host=>hostName * fix: 修复无法握手 --- src/index.js | 5 +++-- src/websocket.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 0457ac2..f19c44f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ const YuFlux = require("./websocket"); const yuFlux = new YuFlux("http://localhost:8000"); -yuFlux.on("upgrade", (res, socket, head) => { - console.error("res.headers"); + +yuFlux.on("upgrade", (res) => { + console.error(res.headers, "res.headers"); }); diff --git a/src/websocket.js b/src/websocket.js index e044e2c..a3c630c 100644 --- a/src/websocket.js +++ b/src/websocket.js @@ -97,7 +97,7 @@ const initWebSocketClient = (websocket, address, protocols, options) => { const defaultPort = isSecure ? 443 : 80; opts.port = parseUrl.port || defaultPort; //处理ipv6 - opts.host = parseUrl.host.startsWith("[") ? parseUrl.host.slice(1, -1) : parseUrl.host; + opts.host = parseUrl.host.startsWith("[") ? parseUrl.hostName.slice(1, -1) : parseUrl.hostName; //请求头 opts.headers = { ...opts.headers,