Fix: change sessionId to get the last path instead of path number 3 or 2 (#111)

This commit is contained in:
Alif Naufal Ilyas 2026-02-25 03:59:43 +07:00 • committed by GitHub
commit 3fb7538149
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,7 +60,7 @@ const handleUpgrade = (request, socket, head) => {
const wsPath = basePath ? `${basePath}/ws/` : '/ws/' const wsPath = basePath ? `${basePath}/ws/` : '/ws/'
if (pathname.startsWith(wsPath)) { if (pathname.startsWith(wsPath)) {
const pathParts = pathname.split('/') const pathParts = pathname.split('/')
const sessionId = basePath ? pathParts[3] : pathParts[2] const sessionId = pathParts[pathParts.length - 1]
const server = wssMap.get(sessionId) const server = wssMap.get(sessionId)
if (server) { if (server) {
server.handleUpgrade(request, socket, head, (ws) => { server.handleUpgrade(request, socket, head, (ws) => {