@@ -30,7 +30,8 @@ int parse_and_validate_port(const std::string& port) {
30
30
}
31
31
32
32
std::pair<std::string, int > split_host_port (const std::string& arg) {
33
- // IPv6, no port
33
+ // remove_brackets only works if no port is specified
34
+ // so if it has an effect only an IPv6 address was specified
34
35
std::string host = remove_brackets (arg);
35
36
if (host.length () < arg.length ())
36
37
return {host, -1 };
@@ -46,6 +47,7 @@ std::pair<std::string, int> split_host_port(const std::string& arg) {
46
47
}
47
48
return {" " , parse_and_validate_port (arg)};
48
49
}
50
+ // host and port found
49
51
return std::make_pair (remove_brackets (arg.substr (0 , colon)),
50
52
parse_and_validate_port (arg.substr (colon + 1 )));
51
53
}
@@ -90,6 +92,7 @@ bool DebugOptions::ParseOption(const std::string& option) {
90
92
argument = option.substr (pos + 1 );
91
93
}
92
94
95
+ // --debug and --inspect are mutually exclusive
93
96
if (option_name == " --debug" ) {
94
97
debugger_enabled_ = true ;
95
98
} else if (option_name == " --debug-brk" ) {
@@ -98,7 +101,15 @@ bool DebugOptions::ParseOption(const std::string& option) {
98
101
} else if (option_name == " --inspect" ) {
99
102
debugger_enabled_ = true ;
100
103
enable_inspector = true ;
101
- } else if (option_name != " --debug-port" || !has_argument) {
104
+ } else if (option_name == " --inspect-brk" ) {
105
+ debugger_enabled_ = true ;
106
+ enable_inspector = true ;
107
+ wait_connect_ = true ;
108
+ } else if ((option_name != " --debug-port" &&
109
+ option_name != " --inspect-port" ) ||
110
+ !has_argument) {
111
+ // only other valid possibility is --debug-port,
112
+ // which requires an argument
102
113
return false ;
103
114
}
104
115
@@ -112,20 +123,17 @@ bool DebugOptions::ParseOption(const std::string& option) {
112
123
#endif
113
124
}
114
125
115
- if (!has_argument) {
116
- return true ;
126
+ // argument can be specified for *any* option to specify host:port
127
+ if (has_argument) {
128
+ std::pair<std::string, int > host_port = split_host_port (argument);
129
+ if (!host_port.first .empty ()) {
130
+ host_name_ = host_port.first ;
131
+ }
132
+ if (host_port.second >= 0 ) {
133
+ port_ = host_port.second ;
134
+ }
117
135
}
118
136
119
- // FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js.
120
- // It seems reasonable to support [address]:port notation
121
- // in net.Server#listen() and net.Socket#connect().
122
- std::pair<std::string, int > host_port = split_host_port (argument);
123
- if (!host_port.first .empty ()) {
124
- host_name_ = host_port.first ;
125
- }
126
- if (host_port.second >= 0 ) {
127
- port_ = host_port.second ;
128
- }
129
137
return true ;
130
138
}
131
139
0 commit comments