@@ -112,19 +112,20 @@ void SplitHostPort(std::string in, uint16_t& portOut, std::string& hostOut)
112
112
size_t colon = in.find_last_of (' :' );
113
113
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
114
114
bool fHaveColon = colon != in.npos ;
115
- bool fBracketed = fHaveColon && (in[0 ]== ' [' && in[colon- 1 ]== ' ]' ); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
116
- bool fMultiColon = fHaveColon && (in.find_last_of (' :' ,colon- 1 ) != in.npos );
117
- if (fHaveColon && (colon== 0 || fBracketed || !fMultiColon )) {
115
+ bool fBracketed = fHaveColon && (in[0 ] == ' [' && in[colon - 1 ] == ' ]' ); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
116
+ bool fMultiColon = fHaveColon && (in.find_last_of (' :' , colon - 1 ) != in.npos );
117
+ if (fHaveColon && (colon == 0 || fBracketed || !fMultiColon )) {
118
118
uint16_t n;
119
119
if (ParseUInt16 (in.substr (colon + 1 ), &n)) {
120
120
in = in.substr (0 , colon);
121
121
portOut = n;
122
122
}
123
123
}
124
- if (in.size ()> 0 && in[0 ] == ' [' && in[in.size ()- 1 ] == ' ]' )
125
- hostOut = in.substr (1 , in.size ()- 2 );
126
- else
124
+ if (in.size () > 0 && in[0 ] == ' [' && in[in.size () - 1 ] == ' ]' ) {
125
+ hostOut = in.substr (1 , in.size () - 2 );
126
+ } else {
127
127
hostOut = in;
128
+ }
128
129
}
129
130
130
131
std::string EncodeBase64 (Span<const unsigned char > input)
0 commit comments