MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getWsUrl

Function getWsUrl

src/server/web/terminal.ts:187–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185// ── WebSocket ────────────────────────────────────────────────────────────────
186
187function getWsUrl(): string {
188 const proto = location.protocol === 'https:' ? 'wss:' : 'ws:'
189 const url = new URL(`${proto}//${location.host}/ws`)
190
191 // Auth token: URL param wins, then localStorage
192 const params = new URLSearchParams(location.search)
193 const token = params.get('token') ?? localStorage.getItem('claude-terminal-token')
194 if (token) {
195 url.searchParams.set('token', token)
196 localStorage.setItem('claude-terminal-token', token)
197 }
198
199 // Pass current terminal dimensions so the PTY is spawned at the right size
200 url.searchParams.set('cols', String(term.cols))
201 url.searchParams.set('rows', String(term.rows))
202
203 return url.toString()
204}
205
206function sendJSON(msg: Record<string, unknown>): void {
207 if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify(msg))

Callers 1

connectFunction · 0.70

Calls 3

getMethod · 0.65
toStringMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected