Skip to content

Commit 11330aa

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

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎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
exportfunctionformatSocketURL(socketPath: string,ssl=false): string{
88
constprotocol=ssl ? 'https' : 'http'
9-
if(process.platform==='win32'){
10-
// Windows named pipes need special encoding
11-
constencodedPath=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+
constencodedPath=process.platform==='win32'
11+
? encodeURIComponent(socketPath)
12+
: socketPath.replace(/\//g,'%2F')
13+
return`${protocol}+unix://${encodedPath}`
1714
}
1815

1916
exportfunctionisSocketURL(url: string): boolean{

0 commit comments

Comments
 (0)