Skip to content

Do not truncate the URL path of IPC URLs at : - #2344

Merged
lpinca merged 2 commits into
websockets:masterfrom
nk-batman21:fix-ipc-url-path-colon
Oct 23, 2026
Merged

lpinca merged 2 commits into
websockets:masterfrom
nk-batman21:fix-ipc-url-path-colon

Conversation

@nk-batman21

Copy link
Copy Markdown
Contributor

When a ws+unix: URL has a : in the URL path or query string, everything after that : is silently dropped. initAsClient() splits on every : and keeps only the first two parts, so the server receives a different path than the one the client asked for.

For example, new WebSocket('ws+unix:/tmp/app.sock:/events?since=2026-10-23T10:00:00Z') sends GET /events?since=2026-10-23T10 and ws+unix:/tmp/app.sock:/events/urn:uuid:42 sends GET /events/urn. Timestamps in the query string, URNs, and Kubernetes API proxy paths such as /api/v1/namespaces/default/pods/name:8080/proxy/ (with kubectl proxy --unix-socket) all hit this.

The IPC connections section of doc/ws.md says that only the IPC path must not include :, so this change keeps everything after the first : as the URL path. When the URL path is omitted, opts.path is now '' instead of undefined, and http.request() still defaults it to / (the existing IPC server test covers that case).

Ran: npm test (439 passing, 1 pending, same pending test as on master) and npm run lint on Node.js 24 on Windows.
Checked: the new test fails on master with '/foo' instead of '/foo:bar?baz=qux:quux', and an end-to-end check over a named pipe now receives /events/urn:uuid:42?since=2026-10-23T10:00:00Z unchanged.

The IPC path and the URL path of a `ws+unix:` URL are separated by the
first `:`, but everything after a second `:` was dropped. For example,
`ws+unix:/tmp/ws.sock:/foo:bar?baz=qux` resulted in a request for
`/foo` instead of `/foo:bar?baz=qux`.

Only the IPC path is documented as not being allowed to contain `:`, so
keep the rest of the string as the URL path.
Comment thread lib/websocket.js Resolved
Comment thread lib/websocket.js Resolved
@lpinca
lpinca merged commit b54ca10 into websockets:master Oct 23, 2026
68 checks passed
@lpinca

lpinca commented Oct 23, 2026

Copy link
Copy Markdown
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants