Skip to content

Commit 11330aa

Browse files
committed
refactor: simplify formatSocketURL logic
1 parent ebf5d01 commit 11330aa

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/nuxi/src/dev/socket.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ import { cleanSocket, getSocketAddress } from 'get-port-please'
66

77
export function formatSocketURL(socketPath: string, ssl = false): string {
88
const protocol = ssl ? 'https' : 'http'
9-
if (process.platform === 'win32') {
10-
// Windows named pipes need special encoding
11-
const encodedPath = encodeURIComponent(socketPath)
12-
return `${protocol}+unix://${encodedPath}`
13-
}
14-
15-
// Unix sockets can use the unix: protocol
16-
return `${protocol}+unix://${socketPath.replace(/\//g, '%2F')}`
9+
// Windows named pipes need special encoding
10+
const encodedPath = process.platform === 'win32'
11+
? encodeURIComponent(socketPath)
12+
: socketPath.replace(/\//g, '%2F')
13+
return `${protocol}+unix://${encodedPath}`
1714
}
1815

1916
export function isSocketURL(url: string): boolean {

0 commit comments

Comments
 (0)