mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: use URL API for WebSocket URL construction in testWs
Parse base URL with new URL() instead of regex stripping so paths/query/fragments in user-entered URLs cannot corrupt the WebSocket endpoint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -278,9 +278,12 @@ async function testHttp(base: string): Promise<boolean> {
|
||||
|
||||
function testWs(base: string): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
const protocol = base.startsWith('https') ? 'wss' : 'ws'
|
||||
const host = base.replace(/^https?:\/\//, '')
|
||||
const ws = new WebSocket(`${protocol}://${host}/ws`)
|
||||
const wsUrl = new URL(base)
|
||||
wsUrl.protocol = wsUrl.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
wsUrl.pathname = '/ws'
|
||||
wsUrl.search = ''
|
||||
wsUrl.hash = ''
|
||||
const ws = new WebSocket(wsUrl.toString())
|
||||
const timeout = setTimeout(() => {
|
||||
ws.close()
|
||||
resolve(false)
|
||||
|
||||
Reference in New Issue
Block a user