INNER CODE UNIT · TypeScript
match
im4codes/imcodes · server/src/index.ts:382
const match = url.pathname.match(/^\/api\/server\/([^/]+)\/ws$/);
const remoteDesktopServerId = url.pathname === REMOTE_DESKTOP_SIGNALING_PATH
? url.searchParams.get(REMOTE_DESKTOP_SERVER_ID_QUERY)
: null;
if (!match && !remoteDesktopServerId) { socket.destroy(); return; }
const serverId = remoteDesktopServerId ?? match![1]!;
const hasBrowserTicket = url.searchParams.has('ticket');
// The query-routed remote desktop signaling endpoint is browser-only.
// Daemons retain the established path-bound endpoint and authentication.
if (remoteDesktopServerId && !hasBrowserTicket) {
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
socket.destroy();
return;
}
if (!hasBrowserTicket) {