INNER CODE UNIT · TypeScript
buildWebSocketUrl
prisma/orm · apps/lsp-playground/src/client/main.ts:125
function buildWebSocketUrl(wsPath: string): string {
const host = `${window.location.host}${wsPath}`;
// nosemgrep: javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
return window.location.protocol === 'https:' ? `wss://${host}` : `ws://${host}`;
}
function basename(path: string): string {
return path.slice(path.lastIndexOf('/') + 1);
}
/**
* A member's display label: its path relative to the scratch root. For a
* flat file this is identical to its basename (no visual change from a
* plain filename); for a file under a subdirectory it disambiguates members
* that would otherwise share a basename across sibling directories.
*/
function relativeLabel(path: string, scratchRootPath: string): string {
const prefix = scratchRootPath.endsWith('/') ? scratchRootPath : `${scratchRootPath}/`;