MCPcopy
hub / github.com/Unitech/pm2 / parseAddr

Function parseAddr

modules/pm2-axon/lib/sockets/sock.js:18–28  ·  view source on GitHub ↗

* Parse address string into components. * Handles both URL-style ("tcp://host:port") and unix socket paths ("/tmp/sock").

(str)

Source from the content-addressed store, hash-verified

16 * Handles both URL-style ("tcp://host:port") and unix socket paths ("/tmp/sock").
17 */
18function parseAddr(str) {
19 try {
20 var u = new URL(str);
21 if (u.protocol === 'unix:') {
22 return { pathname: u.pathname, hostname: null, port: null };
23 }
24 return { hostname: u.hostname, port: u.port, pathname: null };
25 } catch(e) {
26 return { pathname: str, hostname: null, port: null };
27 }
28}
29
30/**
31 * Errors to ignore.

Callers 1

sock.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…