Skip to content

Commit 2995349

Browse files
committed
[minor] Simplify the ws+unix: URL form
Remove the two forward slashes after the scheme. The URL is parsed in the same way and it is easier to grok.
1 parent c22cbc9 commit 2995349

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

doc/ws.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,17 @@ Create a new WebSocket instance.
326326
#### UNIX Domain Sockets
327327

328328
`ws` supports making requests to UNIX domain sockets. To make one, use the
329-
following URL scheme:
329+
following URL form:
330330

331331
```
332-
ws+unix:///absolute/path/to/uds_socket:/pathname?search_params
332+
ws+unix:/absolute/path/to/uds_socket:/pathname?search_params
333333
```
334334

335335
Note that `:` is the separator between the socket path and the URL path. If the
336336
URL path is omitted
337337

338338
```
339-
ws+unix:///absolute/path/to/uds_socket
339+
ws+unix:/absolute/path/to/uds_socket
340340
```
341341

342342
it defaults to `/`.

test/websocket.test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ describe('WebSocket', () => {
15481548

15491549
server.once('upgrade', (req, socket) => {
15501550
socket.end(
1551-
`HTTP/1.1 302 Found\r\nLocation: ws+unix://${socketPath}\r\n\r\n`
1551+
`HTTP/1.1 302 Found\r\nLocation: ws+unix:${socketPath}\r\n\r\n`
15521552
);
15531553
});
15541554

@@ -1589,7 +1589,7 @@ describe('WebSocket', () => {
15891589

15901590
ws.on('close', (code) => {
15911591
assert.strictEqual(code, 1005);
1592-
assert.strictEqual(ws.url, `ws+unix://${socketPath}`);
1592+
assert.strictEqual(ws.url, `ws+unix:${socketPath}`);
15931593
assert.strictEqual(ws._redirects, 1);
15941594

15951595
redirectedServer.close(done);
@@ -1616,7 +1616,7 @@ describe('WebSocket', () => {
16161616
redirectingServer.on('upgrade', (req, socket) => {
16171617
socket.end(
16181618
'HTTP/1.1 302 Found\r\n' +
1619-
`Location: ws+unix://${redirectedServerSocketPath}\r\n\r\n`
1619+
`Location: ws+unix:${redirectedServerSocketPath}\r\n\r\n`
16201620
);
16211621
});
16221622

@@ -1645,10 +1645,10 @@ describe('WebSocket', () => {
16451645
host: 'foo'
16461646
};
16471647

1648-
const ws = new WebSocket(
1649-
`ws+unix://${redirectingServerSocketPath}`,
1650-
{ followRedirects: true, headers }
1651-
);
1648+
const ws = new WebSocket(`ws+unix:${redirectingServerSocketPath}`, {
1649+
followRedirects: true,
1650+
headers
1651+
});
16521652

16531653
const firstRequest = ws._req;
16541654

@@ -1666,7 +1666,7 @@ describe('WebSocket', () => {
16661666
assert.strictEqual(code, 1005);
16671667
assert.strictEqual(
16681668
ws.url,
1669-
`ws+unix://${redirectedServerSocketPath}`
1669+
`ws+unix:${redirectedServerSocketPath}`
16701670
);
16711671
assert.strictEqual(ws._redirects, 1);
16721672

@@ -1723,7 +1723,7 @@ describe('WebSocket', () => {
17231723
host: 'foo'
17241724
};
17251725

1726-
const ws = new WebSocket(`ws+unix://${socketPath}`, {
1726+
const ws = new WebSocket(`ws+unix:${socketPath}`, {
17271727
followRedirects: true,
17281728
headers
17291729
});

0 commit comments

Comments
 (0)