Skip to content

Commit

Permalink
[minor] Simplify the ws+unix: URL form
Browse files Browse the repository at this point in the history
Remove the two forward slashes after the scheme. The URL is parsed in
the same way and it is easier to grok.
  • Loading branch information
lpinca committed Sep 20, 2022
1 parent c22cbc9 commit 2995349
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions doc/ws.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@ Create a new WebSocket instance.
#### UNIX Domain Sockets

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

```
ws+unix:///absolute/path/to/uds_socket:/pathname?search_params
ws+unix:/absolute/path/to/uds_socket:/pathname?search_params
```

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

```
ws+unix:///absolute/path/to/uds_socket
ws+unix:/absolute/path/to/uds_socket
```

it defaults to `/`.
Expand Down
18 changes: 9 additions & 9 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ describe('WebSocket', () => {

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

Expand Down Expand Up @@ -1589,7 +1589,7 @@ describe('WebSocket', () => {

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

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

Expand Down Expand Up @@ -1645,10 +1645,10 @@ describe('WebSocket', () => {
host: 'foo'
};

const ws = new WebSocket(
`ws+unix://${redirectingServerSocketPath}`,
{ followRedirects: true, headers }
);
const ws = new WebSocket(`ws+unix:${redirectingServerSocketPath}`, {
followRedirects: true,
headers
});

const firstRequest = ws._req;

Expand All @@ -1666,7 +1666,7 @@ describe('WebSocket', () => {
assert.strictEqual(code, 1005);
assert.strictEqual(
ws.url,
`ws+unix://${redirectedServerSocketPath}`
`ws+unix:${redirectedServerSocketPath}`
);
assert.strictEqual(ws._redirects, 1);

Expand Down Expand Up @@ -1723,7 +1723,7 @@ describe('WebSocket', () => {
host: 'foo'
};

const ws = new WebSocket(`ws+unix://${socketPath}`, {
const ws = new WebSocket(`ws+unix:${socketPath}`, {
followRedirects: true,
headers
});
Expand Down

0 comments on commit 2995349

Please sign in to comment.